I am trying to trace the GPU activity on an unrooted Samsung S6 using Unity. I have added the libMGD.so to my application and it does appear in my .apk package. I have installed the MGDDaemon and this can see my application.
I start the MGDDaemon and the Mali Graphics Debugger application (Windows8).
Debug | "Connect to target" appears to work and launches a window titled "Capturing Target@/127.0.0.1:5002".
There is no message on the console and no other output appears.
From the MGDDaemon app on device, I select my application which launches.
There are still no traces appearing within the Windows MGD app.
MGD v 3.0.0.6d92cba7
android-non-root\arm\armeabi-v7a\libMGD.so dated 05/08/2015 18:38
Are messages getting lost somewhere?
Thanks in advance,
Ed
I'm facing the same issue, but I don't use Unity for VR.
All the sympthoms, however, are exactly the same:
MGD 3.3.0.1ed1bae6
Samsung Galaxy Tab S 8.4
On the Unity side, there's no way to do that "add to the Android.mk and Activity class" stuff.
So I just put the libMGD.so file from target\android-non-root\arm\armeabi-v7a\ to the project's Assets\Plugins\Android\libs\armeabi-v7a\ folder.
P.S.: the lack of pre-built example app really complicates the process of setting MGR up. It would be much better if there was pre-built APK for the same app as the one profiled in the "samples" folder.
Hi drl,
Unfortunately without the "Activity class stuff", your application is not going to load the MGD interceptor.
Your APK may have libMGD.so inside of it, but its not going to be used unless you explicitly load it.
We're going to have a look and see if there's a way for Unity applications to load libraries.
Thanks,
Jon.
The ability to have the application load the mgd interceptor directly is designed for people who are in a position to make their application do that. If you're not in a position to make your application do that, then I'd recommend the root method as that "just works" without any involvement from the application. Is there something precluding you from using the root method?
Hth,
Chris
Thanks for the replies.
Is there something precluding you from using the root method?
Yes. The warranty void.
Also, I'm working in a small game studio and we're testing our game on the personal devices each of our team has. There's only one "studio device", we don't have a big budget to buy a wide range of devices just for testing.
And none of my co-workers would agree to root their devise for debugging purposes. They're ok to let me use their phones to build the app and check how fast it runs (and/or profile the app with Unity's built-in profiler, which doesn't require rooting). But the're not ok with such a risky thing as rooting the device.
So, yes, non-rooted method for Unity app would be highly, extremely desireable.
Anyway, thanks for making it clear. Today I've rooted our "primary testing device" and with the rooted approach MGD successfully reads data from Unity app.
Unity uses C# for scripting, but as I see the library you provided is written in c++.
In c#, there's a method to load a dll, which was previously compiled by C#, too (and therefore it can be built to any supported platform later).
Or you can call a specific function from the pre-compiled library using [DllImport()]. But I don't know which functions are in this .so file, which of them I need to call and when.
I spent hours trying to get MGD working without voiding my warranty by rooting my device. I finally managed to get it going. Here's what you have to do on the UNITY side (you also have to follow the manual about getting MGDDeamon on your device):
Copy libMGD.so into your Unity Project's Assets/Plugins/Android folder.
Create your own Activity that derives from UnityPlayerActivity and throw the hook in there. Then compile that .java into a .class, then put that .class into a .jar. Finally, place a modified AndroidManifest.xml in your Assets/Plugins/Android folder which will launch your modified activity as the main activity.
Here is the code for the Activity: [Java] Mali Debugger Unity Activity - Pastebin.com
Here's how I compile the .java and .jar it up:
set CurrentDir=%~dp0%
set JdkBin="C:\Program Files\Java\jdk1.8.0_66\bin"
set AndroidJar="B:\Junctions\Android\sdk\platforms\android-23\android.jar"
set UnityJar="B:\Junctions\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Development\Classes\classes.jar"
set TargetJavaDir=%CurrentDir%
set TargetJava="SOME_SOURCE\com\CodingJar\MaliDebugActivity.java"
set TargetJar="SOME_SOURCE\Assets\Plugins\Android\CodingJar-Development.jar"
pushd %JdkBin%
javac -bootclasspath %AndroidJar% -cp %UnityJar% -source 1.6 -target 1.6 %TargetJava%
jar cvf %TargetJar% -C %TargetJavaDir% "com/CodingJar/MaliDebugActivity.class"
popd
The AndroidManifest.xml which you can base yours off of is found in Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Apk
I have only tested this with Google Cardboard and it appears to work. If any Mali engineers are watching, PLEASE supply us with a custom function we can call in your libMGD.so so that it can mark the end of a frame. This way we can use it for VR rendering as well without waiting for you to figure out what to hook instead of eglSwapBuffers.
Cheers.
Thanks for the steps! We get a lot of people asking about MGD + Unity, so I'll raise this with the team and see if we can add some Unity specific steps to our documentation.
As for the VR support, I believe the team are aware of the problem, and we plan to support it.
Hi,
MGD v3.4.1 has been released Mali Graphics Debugger - Mali Developer Center and supports VR with frame detection. Let us know if you have any issues.
Cheers,
Jacek