crittercism / crittercism-unity-android

Crittercism Plugin for Unity Crash Reporting
Other
26 stars 11 forks source link

TestAndroid unity project does not send exceptions to crittercism #2

Closed pgorrow closed 10 years ago

pgorrow commented 10 years ago

Items to include in a ticket: Source of the issue (who reported it): pgorrow (at) wgtmedia.com Version of Unity effected: Tested on both Unity Pro 4.3.2 and 4.3.4 Version of iOS/Android/etc effected: Nexus 7 running 4.3
Version of XCode/Eclipse/Android API: adt-bundle-mac-x86_64-20131030 Date discovered (versus date filed): February 11, 2014

Steps to repeat:

  1. Git clone current crittercism-unity-android repository
  2. Load TestAndroid project in unity
  3. Update Plugins/res/values/strings to use your test app id
  4. Load Crittercism and point at Live Stats for your test app id
  5. Connect and build to android device
  6. Note: once app is transferred to device/executes Live Stats App Loads increments
  7. Press any of the exception inducing buttons

Expected: Viewed on crittercism either exceptions or crashes would increase and switching to the handled exceptions or crashes pane would provide information on crash

Actual: Exception count and crash count do not increase -- crittercism does not see the crash.

Viewed in charles: I can see crittercism sending the app load, and performance messages, but can not see it sending crash information.

  1. Kill and restart app (in case android is a platform that sends bug on next restart)

Expected: Viewed on crittercism either exceptions or crashes would increase and switching to the handled exceptions or crashes pane would provide information on crash

Actual: Exception count and crash count do not increase -- crittercism does not see the crash.

Viewed in charles: crittercism does not send exception information for the exception.

Relavent Log Info:

First init: W/WindowManager( 510): Force-removing child win Window{424b3d38 u0 SurfaceView} from container Window{424af850 u0 com.crittercism.testAndroid/com.unity3d.player.UnityPlayerNativeActivity} I/ActivityManager( 510): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.crittercism.testAndroid/com.unity3d.player.UnityPlayerProxyActivity} from pid 23565 I/ActivityManager( 510): Start proc com.crittercism.testAndroid for activity com.crittercism.testAndroid/com.unity3d.player.UnityPlayerProxyActivity: pid=23586 uid=10079 gids={50079, 3003, 1015, 1028} W/CrittercismAndroid(23586): Attempting to initialize Crittercism W/CrittercismAndroid(23586): Package: com.crittercism.testAndroid W/CrittercismAndroid(23586): Config was successfully set W/CrittercismAndroid(23586): AppID: 52fab100558d6a0e73000007 I/CrittercismInstance(23586): Initializing Crittercism... I/ActivityManager( 510): START u0 {flg=0x10000 cmp=com.crittercism.testAndroid/com.unity3d.player.UnityPlayerNativeActivity} from pid 23586 I/Crittercism(23586): Enabling OPTMZ

Unity init: W/CrittercismAndroid(23586): Config was successfully set W/CrittercismAndroid(23586): Beginning Initialization W/CrittercismAndroid(23586): Already initialized I/Unity (23586): CrittercismAndroidUnity: Registered

Exception log entries: W/CrittercismAndroid(23586): CrittercismTestGUI.OnGUI () (at /Users/pgorrow/Crittercism/crittercism-unity-android/TestAndroid/Assets/Plugins/Crittercism_Android_Scripts/CrittercismTestGUI.cs:18) W/CrittercismAndroid(23586): Unandled Exception Logged I/Unity (23586): NullReferenceException: Object reference not set to an instance of an object I/Unity (23586): at CrittercismTestGUI.OnGUI () [0x0004f] in /Users/pgorrow/Crittercism/crittercism-unity-android/TestAndroid/Assets/Plugins/Crittercism_Android_Scripts/CrittercismTestGUI.cs:18 I/Unity (23586):
I/Unity (23586): (Filename: /Users/pgorrow/Crittercism/crittercism-unity-android/TestAndroid/Assets/Plugins/Crittercism_Android_Scripts/CrittercismTestGUI.cs Line: 18) I/Unity (23586):

Please note that the Unandled Exception Logged message is sent to the log after the crittercism unity plugin calls:

    public static void LogUnhandledException(String name, String reason, String callStack)
    {
        if(!mIsInited || reason == null || name == null)    {   return; }

        Exception ex    = _CreateException("Unhandled Exception", reason, callStack);
        Crittercism.logHandledException(ex);

        CLog("Unandled Exception Logged");
    }

So the exception is being passed to the Crittercism android library. I have verified that it is being caught in _OnDebugLogCallbackHandler, sent to LogUnhandledException and passed through to Crittercism.logHandledException. However from watching the device in charles, no exception seems to be sent to Crittercism.

pgorrow commented 10 years ago

A quick test of the fork created by rough cookie (https://github.com/roughcookie/crittercism-unity-android) shows that his version has no issues sending exceptions to Crittercism. It appears he is using an older version of the crittercism library and has made some code changes but it might be an interesting place to look for possible issues. Since the new version is logging the Unhandled Exception Logged message I don't believe its the initialization race issue -- but something else.

andy-block commented 10 years ago

Hi there,

In case it helps, the two issues we addressed in the rough-cookie fork that might be relevant were:

  1. I encountered a race condition when initialising; because the call to Crittercism.init is done inside a runOnUiThread, there is no guarantee it will be finished before the Init call is complete. Consequently the 'if(_IsPluginInited)' check in CrittercismAndroid.cs could fail, and the system would not be correctly initialised. Initially, I tried to fix this using a semaphore to signal when the runOnUiThread code was complete, and waiting for that before returning from Init. However, that appeared to result in a deadlock, so I instead changed it to signal back to the C# side using UnitySendMessage. This feels a bit ugly to me, but I couldn't see another obvious way forward, and this seems to work fine for our purposes.
  2. The stack traces being reported reflected the java stack (which would always be pretty much the same), not the C# stack where the problem occurred. _CreateException was building a stack trace from the data it was passed, but not calling ex.setStackTrace.

We've not been using Crittercism or Android for about a year now, though, so I'm not up to date on whether these issues may have been addressed. Regards,

Andy

On 13 Feb 2014, at 03:50, Phil Gorrow notifications@github.com wrote:

Items to include in a ticket: Source of the issue (who reported it): pgorrow (at) wgtmedia.com Version of Unity effected: Tested on both Unity Pro 4.3.2 and 4.3.4 Version of iOS/Android/etc effected: Nexus 7 running 4.3

Version of XCode/Eclipse/Android API: adt-bundle-mac-x86_64-20131030 Date discovered (versus date filed): February 11, 2014

Steps to repeat:

  1. Git clone current crittercism-unity-android repository
  2. Load TestAndroid project in unity
  3. Update Plugins/res/values/strings to use your test app id
  4. Load Crittercism and point at Live Stats for your test app id
  5. Connect and build to android device
  6. Note: once app is transferred to device/executes Live Stats App Loads increments
  7. Press any of the exception inducing buttons

Expected: Viewed on crittercism either exceptions or crashes would increase and switching to the handled exceptions or crashes pane would provide information on crash

Actual: Exception count and crash count do not increase -- crittercism does not see the crash.

Viewed in charles: I can see crittercism sending the app load, and performance messages, but can not see it sending crash information.

Kill and restart app (in case android is a platform that sends bug on next restart) Expected: Viewed on crittercism either exceptions or crashes would increase and switching to the handled exceptions or crashes pane would provide information on crash

Actual: Exception count and crash count do not increase -- crittercism does not see the crash.

Viewed in charles: crittercism does not send exception information for the exception.

Relavent Log Info: First init: W/WindowManager( 510): Force-removing child win Window{424b3d38 u0 SurfaceView} from container Window{424af850 u0 com.crittercism.testAndroid/com.unity3d.player.UnityPlayerNativeActivity} I/ActivityManager( 510): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.crittercism.testAndroid/com.unity3d.player.UnityPlayerProxyActivity} from pid 23565 I/ActivityManager( 510): Start proc com.crittercism.testAndroid for activity com.crittercism.testAndroid/com.unity3d.player.UnityPlayerProxyActivity: pid=23586 uid=10079 gids={50079, 3003, 1015, 1028} W/CrittercismAndroid(23586): Attempting to initialize Crittercism W/CrittercismAndroid(23586): Package: com.crittercism.testAndroid W/CrittercismAndroid(23586): Config was successfully set W/CrittercismAndroid(23586): AppID: 52fab100558d6a0e73000007 I/CrittercismInstance(23586): Initializing Crittercism... I/ActivityManager( 510): START u0 {flg=0x10000 cmp=com.crittercism.testAndroid/com.unity3d.player.UnityPlayerNativeActivity} from pid 23586 I/Crittercism(23586): Enabling OPTMZ

Unity init: W/CrittercismAndroid(23586): Config was successfully set W/CrittercismAndroid(23586): Beginning Initialization W/CrittercismAndroid(23586): Already initialized I/Unity (23586): CrittercismAndroidUnity: Registered

Exception log entries: W/CrittercismAndroid(23586): CrittercismTestGUI.OnGUI () (at /Users/pgorrow/Crittercism/crittercism-unity-android/TestAndroid/Assets/Plugins/Crittercism_Android_Scripts/CrittercismTestGUI.cs:18) W/CrittercismAndroid(23586): Unandled Exception Logged I/Unity (23586): NullReferenceException: Object reference not set to an instance of an object I/Unity (23586): at CrittercismTestGUI.OnGUI () [0x0004f] in /Users/pgorrow/Crittercism/crittercism-unity-android/TestAndroid/Assets/Plugins/Crittercism_Android_Scripts/CrittercismTestGUI.cs:18 I/Unity (23586):

I/Unity (23586): (Filename: /Users/pgorrow/Crittercism/crittercism-unity-android/TestAndroid/Assets/Plugins/Crittercism_Android_Scripts/CrittercismTestGUI.cs Line: 18) I/Unity (23586):

Please note that the Unandled Exception Logged message is sent to the log after the crittercism unity plugin calls:

''' public static void LogUnhandledException(String name, String reason, String callStack) { if(!mIsInited || reason == null || name == null) { return; }

Exception ex    = _CreateException("Unhandled Exception", reason, callStack);
Crittercism.logHandledException(ex);

CLog("Unhandled Exception Logged");

} '''

So the exception is being passed to the Crittercism android library. I have verified that it is being caught in _OnDebugLogCallbackHandler, sent to LogUnhandledException and passed through to Crittercism.logHandledException. However from watching the device in charles, no exception seems to be sent to Crittercism.

— Reply to this email directly or view it on GitHub.

pixelknitter commented 10 years ago

@andy-block Thanks for following up on this. We're working to incorporate these fixes into the master branch now and if you have reproduction steps for the race condition that might help us determine a best case solution to resolve it.

@pgorrow we'll also be incorporating the bug fixes to the stack trace handling as well.

Thanks!

andy-block commented 10 years ago

I'm afraid I don't recall the repro steps required for this it's some time ago now. Sorry I can't be more use. Regards,

Andy

On 11 Mar 2014, at 22:34, Edward Freeman notifications@github.com wrote:

@andy-block Thanks for following up on this. We're working to incorporate these fixes into the master branch now and if you have reproduction steps for the race condition that might help us determine a best case solution to resolve it.

@pgorrow we'll also be incorporating the bug fixes to the stack trace handling as well.

Thanks!

— Reply to this email directly or view it on GitHub.

pixelknitter commented 10 years ago

@pgorrow One question I would have for this scenario is this happens on a fresh load of the app and no exceptions are captured? or has at least one exception been captured and then you don't see any after that?

In the latter case, this is likely due to the automatic throttling for Handled Exceptions in our Java Library.

pixelknitter commented 10 years ago

@andy-block that's okay, thanks! :)

pgorrow commented 10 years ago

@NinjaSudo No exceptions are captured. I don't think throttling is the issue.

pixelknitter commented 10 years ago

Oops, looks like this issue wasn't closed, but this should be resolved in the latest version.