Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Native Android Activity plugin issue.

Discussion in 'Android' started by Kukuruz, Jan 8, 2014.

  1. Kukuruz

    Kukuruz

    Joined:
    Jan 8, 2014
    Posts:
    7
    Hi All!
    For the past few days I've been pulling my hair, trying to find what causes a problem with a pretty simple plugin.
    So here comes the explanation:

    I am trying to create a simple plugin, that just starts a native android activity. The activity is to be transparent, because I do not really want to display anything to the user. Now, you may say that I should use a Service if I want no GUI, but just a background execution. Well, in my defense, I will say that I need it to be an activity so that I can start another activity for result. For now, I will just stick to the main native activity( skipping the one for result ) because the problem comes from it.


    Here we begin:

    1. Entry point for the communication -> getting an instance of the java class.
    Well, here is how I create the connection:

    Code (csharp):
    1.  public class SamplePlugin {
    2.         private static SampleUnity mInstance;
    3.        
    4.         public static SampleUnity GetInstance() {
    5.             if(mInstance == null) {
    6.                 mInstance = new SampleUnity(UnityPlayer.currentActivity);
    7.             }
    8.             //Log.i("GET INSTANCE", "GET INSTANCE");
    9.             return mInstance;
    10.         }
    11.     }
    This way I get the instance of SampleUnity class:

    Code (csharp):
    1.  public class SampleUnity {
    2.        
    3.         private Activity mActivity;
    4.        
    5.         public SampleUnity( final Activity activity ) {
    6.             this.mActivity = activity;
    7.         }
    8.    
    9.         public void StartNewActivity( ) {
    10.    
    11.             Intent intent = new Intent(mActivity, NewActivity.class);
    12.    
    13.             mActivity.startActivity(intent);
    14.         }
    15.     }
    Now let's look at the new activity:

    Code (csharp):
    1. public class NewActivity extends Activity{
    2.    
    3.         @Override
    4.         public void onCreate(final Bundle mSavedInstanceState) {
    5.             super.onCreate(mSavedInstanceState);
    6.      
    7.             // Can go with or without this contentView( I do not really need it ).
    8.             Resources res = getResources();
    9.             setContentView( res.getIdentifier("new_activity", "layout", this.getPackageName()));
    10.          
    11.             //Just for now, I use finish(), but actually startActivityForResult goes here.
    12.             finish();
    13.         }
    14.     }
    Ewww, what? A whole new activity just to close it? Well....I want to just hit you in the face with new window...
    Okay so, this activity lifecycle goes as ----> onCreate() ->onDestroy()
    Now the activity disappears and I am back in the game.

    Now how a look at the C# part in Unity:

    Code (csharp):
    1. public class SamplePlugin {
    2.     private static AndroidJavaObject _plugin;
    3.  
    4.     static SamplePlugin() {
    5.         if( Application.platform != RuntimePlatform.Android )
    6.             return;
    7.        
    8.         // find the plugin instance
    9.         using( AndroidJavaClass pluginClass = new AndroidJavaClass( "com.me.unity.myplugin.SamplePlugin" ) )
    10.             _plugin = pluginClass.CallStatic<AndroidJavaObject>( "GetInstance" );
    11.     }
    12.  
    13.     public static void StartNewActivity(  ) {
    14.         if( Application.platform != RuntimePlatform.Android )
    15.             return;
    16.  
    17.         _plugin.Call( "StartNewActivity");
    18.     }
    19. }
    And I put these lines in the manifest:

    Code (csharp):
    1. <activity android:name="com.me.unity.myplugin.NewActivity" >
    2.  </activity>
    And now, when I click the big red button in game, the magic happens:::: my new activity is launched
    and immediately destroyed( "adb shell dumpsys activity" confirmed that! ).

    Here comes the BOOM:

    Now ... the real part of the problem.
    When I am back in my game, I quit the game as soon as possible( using Application.Quit() ).
    "Oh, mah game is closed." - my first thought after that.
    Well..... I tried launching the game again and the big bad dump hit me in the face:

    Code (csharp):
    1. ActivityManager(498): Displayed com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity: +869ms (total +9s448ms)
    2. DEBUG(26059): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    3. DEBUG(26059): Build fingerprint: 'google/nakasi/grouper:4.4/KRT16S/920375:user/release-keys'
    4. DEBUG(26059): Revision: '0'
    5. DEBUG(26059): pid: 11354, tid: 11443, name: Thread-1060  >>> com.me.myunitygame <<<
    6. DEBUG(26059): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
    7. DEBUG(26059):     r0 00000000  r1 6abd28d0  r2 00000001  r3 00000000
    8. DEBUG(26059):     r4 00010000  r5 6acd0810  r6 6abd28d0  r7 6b055fbc
    9. DEBUG(26059):     r8 6b153b10  r9 6b055fb4  sl 6d01a9b8  fp 6b153b24
    10. DEBUG(26059):     ip 00000001  sp 6b1539f0  lr 401672c7  pc 6a259b00  cpsr 20000010
    11. DEBUG(26059):     d0  0000001c00000010  d1  0000000000000000
    12. DEBUG(26059):     d2  0000000000000000  d3  0000000000000000
    13. DEBUG(26059):     d4  0000000000000000  d5  00000494e2000000
    14. DEBUG(26059):     d6  4492800044480000  d7  3f8000003f800000
    15. DEBUG(26059):     d8  0000000000000000  d9  0000000000000000
    16. DEBUG(26059):     d10 0000000000000000  d11 0000000000000000
    17. DEBUG(26059):     d12 0000000000000000  d13 0000000000000000
    18. DEBUG(26059):     d14 0000000000000000  d15 0000000000000000
    19. DEBUG(26059):     d16 000000000000001c  d17 223d656d616e206c
    20. DEBUG(26059):     d18 00328c7400316d3c  d19 0034cae40033abac
    21. DEBUG(26059):     d20 0008f9c00008f9c0  d21 0008f9c00008f9c0
    22. DEBUG(26059):     d22 0000000100000001  d23 0000000100000001
    23. DEBUG(26059):     d24 0000002a00000029  d25 0000002c0000002b
    24. DEBUG(26059):     d26 00944026008fc024  d27 009d40280098c027
    25. DEBUG(26059):     d28 0000002900000028  d29 0000002b0000002a
    26. DEBUG(26059):     d30 00a6402a00a1c029  d31 00af402c00aac02b
    27. DEBUG(26059):     scr 80000010
    28. DEBUG(26059): backtrace:
    29. DEBUG(26059):     #00  pc 000b6b00  /data/app-lib/com.me.myunitygame-1/libunity.so
    30. DEBUG(26059):     #01  pc 0027a088  /data/app-lib/com.me.myunitygame-1/libunity.so
    31. DEBUG(26059):     #02  pc 003a26b4  /data/app-lib/com.me.myunitygame-1/libunity.so
    32. DEBUG(26059):     #03  pc 003a3084  /data/app-lib/com.me.myunitygame-1/libunity.so
    33. DEBUG(26059):     #04  pc 003a3210  /data/app-lib/com.me.myunitygame-1/libunity.so
    34. DEBUG(26059):     #05  pc 0001dbcc  /system/lib/libdvm.so (dvmPlatformInvoke+112)
    35. DEBUG(26059):     #06  pc 0004e123  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
    36. DEBUG(26059):     #07  pc 00026fe0  /system/lib/libdvm.so
    37. DEBUG(26059):     #08  pc 0002dfa0  /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
    38. DEBUG(26059):     #09  pc 0002b638  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
    39. DEBUG(26059):     #10  pc 00060581  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
    40. DEBUG(26059):     #11  pc 000605a5  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
    41. DEBUG(26059):     #12  pc 0005528b  /system/lib/libdvm.so
    42. DEBUG(26059):     #13  pc 0000d228  /system/lib/libc.so (__thread_entry+72)
    43. DEBUG(26059):     #14  pc 0000d3c0  /system/lib/libc.so (pthread_create+240)
    44. DEBUG(26059): stack:
    45. DEBUG(26059):          6b1539b0  00000010  
    46. DEBUG(26059):          6b1539b4  401672c7  /system/lib/libc.so
    47. DEBUG(26059):          6b1539b8  00010000  
    48. DEBUG(26059):          6b1539bc  6abd28d0  
    49. DEBUG(26059):          6b1539c0  6abd28d0  
    50. DEBUG(26059):          6b1539c4  6b055fbc  
    51. DEBUG(26059):          6b1539c8  6b153b10  
    52. DEBUG(26059):          6b1539cc  40163d01  /system/lib/libc.so (memalign+12)
    53. DEBUG(26059):          6b1539d0  6abaeb38  /data/app-lib/com.me.myunitygame-1/libunity.so
    54. DEBUG(26059):          6b1539d4  6a2580d0  /data/app-lib/com.me.myunitygame-1/libunity.so
    55. DEBUG(26059):          6b1539d8  00010000  
    56. DEBUG(26059):          6b1539dc  6a258118  /data/app-lib/com.me.myunitygame-1/libunity.so
    57. DEBUG(26059):          6b1539e0  00010000  
    And 1 more kilometer of DEBUG log which I am going to paste here...

    After that the exceptions come( obviously because the process gets killed, duh ) :

    Code (csharp):
    1. ActivityManager(498):   Force finishing activity com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity
    2. InputDispatcher(498): channel '42893930 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    3. InputDispatcher(498): channel '42893930 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    4. InputDispatcher(498): channel '428c0080 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    5. InputDispatcher(498): channel '428c0080 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    6. Zygote(123): Process 11354 terminated by signal (11)
    7. dalvikvm(498): GC_FOR_ALLOC freed 1007K, 19% free 18269K/22344K, paused 77ms, total 77ms
    8. WindowState(498): WIN DEATH: Window{428d6f08 u0 SurfaceView}
    9. dalvikvm(498): GC_FOR_ALLOC freed 589K, 19% free 18178K/22344K, paused 65ms, total 65ms
    10. InputDispatcher(498): Attempted to unregister already unregistered input channel '42893930 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)'
    11. WindowState(498): WIN DEATH: Window{42893930 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    12. InputDispatcher(498): Attempted to unregister already unregistered input channel '428c0080 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)'
    13. WindowState(498): WIN DEATH: Window{42b55ac0 u0 SurfaceView}
    14. WindowState(498): WIN DEATH: Window{428c0080 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    15. ActivityManager(498): Exception thrown during pause
    16. ActivityManager(498): android.os.DeadObjectException
    17. ActivityManager(498):   at android.os.BinderProxy.transact(Native Method)
    18. ActivityManager(498):   at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:660)
    19. ActivityManager(498):   at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:755)
    20. ActivityManager(498):   at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2408)
    21. ActivityManager(498):   at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2279)
    22. ActivityManager(498):   at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2018)
    23. ActivityManager(498):   at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:9389)
    24. ActivityManager(498):   at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:9284)
    25. ActivityManager(498):   at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:9926)
    26. ActivityManager(498):   at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:9478)
    27. ActivityManager(498):   at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
    28. ActivityManager(498): Process com.me.myunitygame (pid 11354) has died.
    And one NullPointerException , or two...
    So. After the process is killed I can launch my game again.

    Remember when I said that I wanted to make my activity transparent? Well, yeah, I just add a theme to my activity in the manifest:

    Code (csharp):
    1. <activity android:name="com.me.unity.myplugin.NewActivity"
    2.                       android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
    3. </activity>
    or

    Code (csharp):
    1. <activity android:name="com.me.unity.myplugin.NewActivity"
    2.                       android:theme="@android:style/Theme.NoDisplay">
    3. </activity>
    This does the trick.

    So...here are some different scenarios :
    - When I launch the native activity, it executes and finishes. Then I am back in my game. If I minimize the game, then open it again( its state is restored ) and THEN I quit it, it quits as it should. No problems occur.

    - When I launch the native activity, it executes and finishes. Then I am back in my game. Sometimes(not always) if I wait a few seconds before I quit it, it quits normally. No problems occur( sometimes ).

    - When I put Theme.NoDisplay on my activity, after it finishes and I am back in the game, I quit the game and the problem I mentioned happens( 100% ).

    - I put Theme.Translucent.NoTitleBar.Fullscreen on my activity. After it finishes, I am back in the game. I wait a few seconds and quit the game. Sometimes the problem occurs, sometimes not. ( 50% ).

    - I put no theme on my activity. After it finishes, I am back in the game. I wait a few seconds( less than when I put Translucent theme), I quit the game and usually there is not problem. If I quit the game too fast, the problem occurs.

    - Setting content view in my activity ( setContentView ) makes the game more likely to quit without problem. But still, the problem occurs sometimes.

    - I tried with BroadcastReceiver from which I launch the new activity -> same behaviour.

    - I cannot confirm 100% but if I let my activity go through all of its states when created( not call finish in onCreate ) , the problem does not occur( or may happen but really rarely ).

    - I tried putting a timer in onCreate, which executes finish() on my activity ( through a handler - on the main thread ) when it finishes. I tested it a few times, and when the native activity is closed and I quit the game, there is not problem.

    When the problem occurs, I usually execute the "adb shell dump sys activity" in the terminal, and I see that UnityPlayerNativeActivity is in the state: Activities Waiting to Stop.

    Soooo I smell there is some background dark magic going on, which somehow keeps the process alive.

    So these are the scenarios I can think of ( that I have tested ). There may be 1 or 2 I am missing but I tested tons of different options, and nothing helped at 100%.
    To me, this behaviour is pretty much UNKNOWN. So I hope there is somebody who can tell me where I go wrong, or what option can I try to solve the issue.

    Oh... and I hope I did not forget to show any important part of the project.

    Here comes my apology:
    - Sorry if I misconstructed, misspelled or anything similar with the English language.
    - Sorry for burning your eyes with the long post.
    - I want to apologize to myself for creating a big bald spot on the back of my head.
     
    Last edited: Jan 8, 2014
  2. jvil

    jvil

    Joined:
    Jul 13, 2012
    Posts:
    263
    SIGSEV 11 and memory address 0x00000000 as your case it's commonly a NullPointer issue.

    I would start looking if UnityPlayer.currentActivity returns the current activity Context on your Activity.

    Also, if you are using Android layouts and other resources, you need to copy them on Android/Plugins/res folder or similar because the R class is regenerated by Unity when building your game.
     
    Last edited: Jan 10, 2014
  3. Kukuruz

    Kukuruz

    Joined:
    Jan 8, 2014
    Posts:
    7
    Hi.
    I am not sure what you mean with " if UnityPlayer.currentActivity returns the current activity Context on your Activity", but when the new activity is started, it is placed in the UnityPlayerNativeActivity ' s task back stack, which creates the following stack:

    Task #NUMBER:
    #2 : com.me.myunitygame / com.me.unity.myplugin.NewActivity;
    #1 : com.me.myunitygame / com.unity3d.player.UnityPlayerNativeActivity;

    This looks good to me. So when I finish the NewActivity, it is properly removed from the back stack. After that the focus goes directly to UnityPlayerNativeActivity, which still looks good to me. When I close the application (depending on one of the scenarios mentioned above ), the problem occurs.
    Strange thing is that on some devices( usually with older android OS ) there is NO problem at all. It never occurs.
     
  4. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    What does your manifest look like?
     
  5. Kukuruz

    Kukuruz

    Joined:
    Jan 8, 2014
    Posts:
    7
    Code (csharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.me.myunitygame" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
    3.   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
    4.   <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
    5.     <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
    6.       <intent-filter>
    7.         <action android:name="android.intent.action.MAIN" />
    8.         <category android:name="android.intent.category.LAUNCHER" />
    9.       </intent-filter>
    10.       <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    11.     </activity>
    12.  
    13.     <activity android:name="com.me.unity.myplugin.NewActivity"
    14.              android:theme="@android:style/Theme.Translucent.NoTitleBar">
    15.     </activity>
    16.    
    17. </application>
    18.  
    19.         <uses-permission android:name="android.permission.INTERNET"/>
    20.         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    21.         <uses-permission android:name="android.permission.GET_TASKS"/>
    22.         <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    23.         <uses-permission android:name="com.android.vending.BILLING"/>
    24.         <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    25.         <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    26.  
    27. </manifest>
     
  6. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Yeah, that looks ok. Do you mind running a "Development" build and see if you can get some symbols out of the Unity library? And possibly posting the entire logcat so I can see what is leading up to the crash.

    Or you could file a proper bug report ;)
     
  7. Kukuruz

    Kukuruz

    Joined:
    Jan 8, 2014
    Posts:
    7
    Hi. Sorry for replying so late.

    So here are the logs using development build:

    First start:

    Code (csharp):
    1. 01-13 15:01:01.441: I/ActivityManager(478): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity} from pid 861
    2. 01-13 15:01:01.501: I/ActivityManager(478): Start proc com.me.myunitygame for activity com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity: pid=18601 uid=10094 gids={50094, 3003, 1015, 1028}
    3. 01-13 15:01:01.511: D/dalvikvm(18601): Late-enabling CheckJNI
    4. 01-13 15:01:01.581: D/dalvikvm(18601): Trying to load lib /data/app-lib/com.me.myunitygame-2/libmain.so 0x414529b8
    5. 01-13 15:01:01.581: D/dalvikvm(18601): Added shared lib /data/app-lib/com.me.myunitygame-2/libmain.so 0x414529b8
    6. 01-13 15:01:01.591: I/Unity(18601): gles_mode = 0 (integer)
    7. 01-13 15:01:01.591: I/Unity(18601): splash_mode = 0 (integer)
    8. 01-13 15:01:01.591: I/Unity(18601): hide_status_bar = True (bool)
    9. 01-13 15:01:01.591: I/Unity(18601): useObb = False (bool)
    10. 01-13 15:01:01.591: I/Unity(18601): development_player = True (bool)
    11. 01-13 15:01:01.631: D/Unity(18601): surfaces: attach glview
    12. 01-13 15:01:02.081: I/Unity(18601): onResume
    13. 01-13 15:01:02.371: D/Unity(18601): [EGL] Attaching window 0x68ce5998
    14. 01-13 15:01:02.411: I/Unity(18601): windowFocusChanged: true
    15. 01-13 15:01:02.421: D/Unity(18601): SystemInfo CPU = ARMv7 VFPv3 NEON, Cores = 4, Memory = 974mb
    16. 01-13 15:01:02.431: I/ActivityManager(478): Displayed com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity: +946ms
    17. 01-13 15:01:03.121: D/Unity(18601): [SHA1] 81b2a76aa88bc8178e778a34bcc47e930bc03f31   16599592 bytes ~ lib/armeabi-v7a/libunity.so
    18. 01-13 15:01:03.121: D/Unity(18601): Mono path[0] = '/data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed'
    19. 01-13 15:01:03.121: D/Unity(18601): Mono config path = 'assets/bin/Data/Managed'
    20. 01-13 15:01:03.121: D/Unity(18601): PlayerConnection initialized from /data/app/com.me.myunitygame-2.apk/assets/bin/Data (debug = 0)
    21. 01-13 15:01:03.131: D/Unity(18601): PlayerConnection initialized network socket : 0.0.0.0 55482
    22. 01-13 15:01:03.131: D/Unity(18601): PlayerConnection initialized unix socket : Unity-com.me.myunitygame
    23. 01-13 15:01:03.131: D/Unity(18601): Multi-casting "[IP] 10.7.3.127 [Port] 55482 [Flags] 2 [Guid] 20878813 [EditorId] 2156900419 [Version] 1048832 [Id] AndroidPlayer(asus_Nexus_7:10.7.3.127) [Debug] 0" to [225.0.0.222:54997]...
    24. 01-13 15:01:03.181: W/mono(18601): Symbol file /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/mscorlib.dll.mdb doesn't match image /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/mscorlib.dll
    25. 01-13 15:01:03.211: W/mono(18601): Symbol file /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/mscorlib.dll.mdb doesn't match image /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/mscorlib.dll
    26. 01-13 15:01:03.241: D/Unity(18601): InitializeMonoFromMain OK (61b1aee0)
    27. 01-13 15:01:03.241: D/Unity(18601): PlayerConnection already initialized - listening to [10.7.3.127:55482]
    28. 01-13 15:01:03.261: D/Unity(18601): PlayerInitEngineNoGraphics OK
    29. 01-13 15:01:03.261: D/Unity(18601): GfxDevice: creating device client; threaded=0
    30. 01-13 15:01:03.261: D/libEGL(18601): loaded /system/lib/egl/libEGL_tegra.so
    31. 01-13 15:01:03.271: D/libEGL(18601): loaded /system/lib/egl/libGLESv1_CM_tegra.so
    32. 01-13 15:01:03.281: D/libEGL(18601): loaded /system/lib/egl/libGLESv2_tegra.so
    33. 01-13 15:01:03.291: D/Unity(18601): [EGL] Request: ES2 RGB24 888 24/8
    34. 01-13 15:01:03.291: D/Unity(18601): [EGL] Selected: ES2 RGB24 888 16NLZ/8
    35. 01-13 15:01:03.301: D/Unity(18601): Renderer: NVIDIA Tegra 3
    36. 01-13 15:01:03.301: D/Unity(18601): Vendor:   NVIDIA Corporation
    37. 01-13 15:01:03.301: D/Unity(18601): Version:  OpenGL ES 2.0 14.01002
    38. 01-13 15:01:03.301: D/Unity(18601): GL_OES_rgb8_rgba8 GL_OES_EGL_sync GL_OES_fbo_render_mipmap GL_NV_depth_nonlinear GL_NV_draw_path GL_NV_texture_npot_2D_mipmap GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_vertex_half_float GL_OES_mapbuffer GL_NV_draw_buffers GL_NV_multiview_draw_buffers GL_EXT_Cg_shader GL_EXT_packed_float GL_OES_texture_half_float GL_EXT_texture_array GL_OES_compressed_ETC1_RGB8_texture GL_EXT_texture_compression_latc GL_NV_texture_compression_latc GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_NV_texture_compression_s3tc GL_EXT_texture_filter_anisotropic GL_NV_get_tex_image GL_NV_read_buffer GL_NV_shader_framebuffer_fetch GL_NV_copy_image GL_NV_fbo_color_attachments GL_EXT_bgra GL_EXT_texture_format_BGRA8888 GL_EXT_unpack_subimage GL_NV_pack_subimage GL_NV_texture_compression_s3tc_update GL_NV_read_depth GL_NV_read_stencil GL_NV_uniform_buffer_object GL_EXT_robustness GL_OES_standard_derivatives GL_NV_EGL_stream_consumer_external GL_NV_3dvision_settings GL_EXT_debug_marker GL_EXT_debug_label GL_NV_
    39. 01-13 15:01:03.301: D/Unity(18601): coverage_sample GL_EXT_occlusion_query_boolean GL_NV_timer_query
    40. 01-13 15:01:03.301: D/Unity(18601): Creating OpenGLES2.0 graphics device
    41. 01-13 15:01:03.301: D/Unity(18601): InitializeGfxDevice OK
    42. 01-13 15:01:03.301: D/Unity(18601): Initialize engine version: 4.3.0f4 (e01000627d60)
    43. 01-13 15:01:03.331: W/libc(18601): pthread_create sched_setscheduler call failed: Operation not permitted
    44. 01-13 15:01:03.331: D/Unity(18601): Begin MonoManager ReloadAssembly
    45. 01-13 15:01:03.351: D/Unity(18601): Platform assembly: /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/UnityEngine.dll (this message is harmless)
    46. 01-13 15:01:03.351: D/Unity(18601): Loading /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/UnityEngine.dll into Unity Child Domain
    47. 01-13 15:01:03.411: D/Unity(18601): Platform assembly: /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/Assembly-CSharp.dll (this message is harmless)
    48. 01-13 15:01:03.411: D/Unity(18601): Loading /data/app/com.me.myunitygame-2.apk/assets/bin/Data/Managed/Assembly-CSharp.dll into Unity Child Domain
    49. 01-13 15:01:03.431: D/Unity(18601): - Completed reload, in  0.103 seconds
    50. 01-13 15:01:03.451: D/Unity(18601): PlayerInitEngineGraphics OK
    51. 01-13 15:01:03.451: D/Unity(18601): Found 13 native sensors
    52. 01-13 15:01:03.451: D/Unity(18601): Sensor :        Accelerometer ( 1) ; 0.039227 / 0.00s ; MPL Accelerometer / Invensense
    53. 01-13 15:01:03.451: D/Unity(18601): Sensor :        Accelerometer ( 1) ; 0.039227 / 0.00s ; MPL Accelerometer / Invensense
    54. 01-13 15:01:03.801: W/SensorService(478): sensor 00000001 already enabled in connection 0x64aa85a0 (ignoring)
    55. 01-13 15:01:03.801: D/Unity(18601): Sensor :        Accelerometer ( 1) ; 0.039227 / 0.00s ; MPL Accelerometer / Invensense
    56. 01-13 15:01:06.901: D/dalvikvm(18601): GC_CONCURRENT freed 282K, 6% free 7397K/7828K, paused 3ms+2ms, total 18ms
    57. 01-13 15:01:06.921: I/ActivityManager(478): START u0 {cmp=com.me.myunitygame/com.me.unity.myplugin.NewActivity} from pid 18601
    58. 01-13 15:01:07.001: D/dalvikvm(478): GC_FOR_ALLOC freed 2229K, 21% free 17750K/22348K, paused 69ms, total 69ms
    59. 01-13 15:01:07.501: W/ActivityManager(478): Activity pause timeout for ActivityRecord{41b7d5d0 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    60. 01-13 15:01:07.831: I/Unity(18601): onPause
    61. 01-13 15:01:07.851: D/Unity(18601): Sensor :        Accelerometer ( 1) ; 0.039227 / 0.00s ; MPL Accelerometer / Invensense
    62. 01-13 15:01:07.871: D/NEW ACTIVITY(18601): New Activity Created...Time to finish it....
    63. 01-13 15:01:07.881: I/Unity(18601): windowFocusChanged: false
    64. 01-13 15:01:07.881: I/Unity(18601): windowFocusChanged: true
    65. 01-13 15:01:07.881: W/InputMethodManagerService(478): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41b7e8f0 attribute=null, token = android.os.BinderProxy@41a7afb8
    66. 01-13 15:01:08.831: I/Unity(18601): onResume
    67. 01-13 15:01:08.851: D/Unity(18601): Sensor :        Accelerometer ( 1) ; 0.039227 / 0.00s ; MPL Accelerometer / Invensense
    68. 01-13 15:01:13.081: I/Unity(18601): Quitting application...
    69. 01-13 15:01:13.081: I/Unity(18601): UnityEngine.Debug:Internal_Log(Int32, String, Object)
    70. 01-13 15:01:13.081: I/Unity(18601): UnityEngine.Debug:Log(Object)
    71. 01-13 15:01:13.081: I/Unity(18601): UnityEngine.MonoBehaviour:print(Object)
    72. 01-13 15:01:13.081: I/Unity(18601): MainScript:Update() (at /UnityProjects/MyUnityGame/Assets/MainScript.cs:13)
    73. 01-13 15:01:13.081: I/Unity(18601):  
    74. 01-13 15:01:13.081: I/Unity(18601): (Filename: /UnityProjects/MyUnityGame/Assets/MainScript.cs Line: 13)
    75. 01-13 15:01:13.601: W/ActivityManager(478): Activity pause timeout for ActivityRecord{41b7d5d0 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    76. 01-13 15:01:14.331: I/Unity(18601): onPause
    77. 01-13 15:01:14.521: D/Unity(18601): ASensorManager_destroyEventQueue returned 0
    78. 01-13 15:01:14.521: I/Unity(18601): windowFocusChanged: false

    Second start after closing app( problematic ) :

    Code (csharp):
    1. 01-13 15:02:07.241: I/ActivityManager(478): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity} from pid 861
    2. 01-13 15:02:07.321: I/Unity(18601): gles_mode = 0 (integer)
    3. 01-13 15:02:07.321: I/Unity(18601): splash_mode = 0 (integer)
    4. 01-13 15:02:07.321: I/Unity(18601): hide_status_bar = True (bool)
    5. 01-13 15:02:07.321: I/Unity(18601): useObb = False (bool)
    6. 01-13 15:02:07.321: I/Unity(18601): development_player = True (bool)
    7. 01-13 15:02:07.331: D/Unity(18601): surfaces: attach glview
    8. 01-13 15:02:07.821: I/Unity(18601): onResume
    9. 01-13 15:02:08.111: D/Unity(18601): [EGL] Attaching window 0x68b3cbf0
    10. 01-13 15:02:08.161: I/Unity(18601): windowFocusChanged: true
    11. 01-13 15:02:08.161: A/libc(18601): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 18673 (Thread-1322)
    12. 01-13 15:02:08.171: I/ActivityManager(478): Displayed com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity: +889ms (total +60s671ms)
    13. 01-13 15:02:08.271: I/DEBUG(18579): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    14. 01-13 15:02:08.271: I/DEBUG(18579): Build fingerprint: 'google/nakasi/grouper:4.2.2/JDQ39/573038:user/release-keys'
    15. 01-13 15:02:08.271: I/DEBUG(18579): Revision: '0'
    16. 01-13 15:02:08.271: I/DEBUG(18579): pid: 18601, tid: 18673, name: Thread-1322  >>> com.me.myunitygame <<<
    17. 01-13 15:02:08.271: I/DEBUG(18579): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
    18. 01-13 15:02:08.641: I/DEBUG(18579):     r0 00000000  r1 6aa7ca40  r2 00000001  r3 00000000
    19. 01-13 15:02:08.641: I/DEBUG(18579):     r4 00010000  r5 00000000  r6 6aa75814  r7 6aa7ca40
    20. 01-13 15:02:08.641: I/DEBUG(18579):     r8 6afdfc78  r9 40bc3fb4  sl 61eb84b0  fp 6afdfc8c
    21. 01-13 15:02:08.641: I/DEBUG(18579):     ip 00000000  sp 6afdfb48  lr 4017a64d  pc 69e9db5c  cpsr 20000010
    22. 01-13 15:02:08.641: I/DEBUG(18579):     d0  0000008543052000  d1  4496b00043052000
    23. 01-13 15:02:08.641: I/DEBUG(18579):     d2  3f00000044480000  d3  3f00000000000000
    24. 01-13 15:02:08.641: I/DEBUG(18579):     d4  0000000000000000  d5  3f80000080000000
    25. 01-13 15:02:08.641: I/DEBUG(18579):     d6  3f80000044480000  d7  4496a0004496a000
    26. 01-13 15:02:08.641: I/DEBUG(18579):     d8  0000000000000000  d9  0000000000000000
    27. 01-13 15:02:08.641: I/DEBUG(18579):     d10 0000000000000000  d11 0000000000000000
    28. 01-13 15:02:08.641: I/DEBUG(18579):     d12 0000000000000000  d13 0000000000000000
    29. 01-13 15:02:08.641: I/DEBUG(18579):     d14 0000000000000000  d15 0000000000000000
    30. 01-13 15:02:08.641: I/DEBUG(18579):     d16 000000000000010b  d17 000000000000010b
    31. 01-13 15:02:08.641: I/DEBUG(18579):     d18 0000000000000000  d19 0000000000000000
    32. 01-13 15:02:08.641: I/DEBUG(18579):     d20 0000000000000000  d21 3ff0000000000000
    33. 01-13 15:02:08.641: I/DEBUG(18579):     d22 8000000000000000  d23 0000000000000000
    34. 01-13 15:02:08.641: I/DEBUG(18579):     d24 0000000000000000  d25 8000000000000000
    35. 01-13 15:02:08.641: I/DEBUG(18579):     d26 3ff0000000000000  d27 0067006700670067
    36. 01-13 15:02:08.641: I/DEBUG(18579):     d28 0100010001000100  d29 0100010001000100
    37. 01-13 15:02:08.641: I/DEBUG(18579):     d30 0000000100000001  d31 0000000100000001
    38. 01-13 15:02:08.641: I/DEBUG(18579):     scr 80000090
    39. 01-13 15:02:08.651: I/DEBUG(18579): backtrace:
    40. 01-13 15:02:08.651: I/DEBUG(18579):     #00  pc 000b8b5c  /data/app-lib/com.me.myunitygame-2/libunity.so (MemoryManager::ThreadInitialize(unsigned int)+128)
    41. 01-13 15:02:08.651: I/DEBUG(18579):     #01  pc 0028745c  /data/app-lib/com.me.myunitygame-2/libunity.so (RuntimeInitialize()+48)
    42. 01-13 15:02:08.651: I/DEBUG(18579):     #02  pc 003fe61c  /data/app-lib/com.me.myunitygame-2/libunity.so (UnityInitApplication()+8)
    43. 01-13 15:02:08.651: I/DEBUG(18579):     #03  pc 003feebc  /data/app-lib/com.me.myunitygame-2/libunity.so (UnityPlayerLoop()+664)
    44. 01-13 15:02:08.651: I/DEBUG(18579):     #04  pc 004039b8  /data/app-lib/com.me.myunitygame-2/libunity.so (nativeRender(_JNIEnv*, _jobject*)+80)
    45. 01-13 15:02:08.651: I/DEBUG(18579):     #05  pc 0001e290  /system/lib/libdvm.so (dvmPlatformInvoke+112)
    46. 01-13 15:02:08.651: I/DEBUG(18579):     #06  pc 0004d411  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+396)
    47. 01-13 15:02:08.651: I/DEBUG(18579):     #07  pc 000276a0  /system/lib/libdvm.so
    48. 01-13 15:02:08.651: I/DEBUG(18579):     #08  pc 0002b57c  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
    49. 01-13 15:02:08.651: I/DEBUG(18579):     #09  pc 0005fc31  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
    50. 01-13 15:02:08.651: I/DEBUG(18579):     #10  pc 0005fc5b  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
    51. 01-13 15:02:08.651: I/DEBUG(18579):     #11  pc 000547d7  /system/lib/libdvm.so
    52. 01-13 15:02:08.651: I/DEBUG(18579):     #12  pc 0000e3d8  /system/lib/libc.so (__thread_entry+72)
    53. 01-13 15:02:08.651: I/DEBUG(18579):     #13  pc 0000dac4  /system/lib/libc.so (pthread_create+160)
    54. 01-13 15:02:08.651: I/DEBUG(18579): stack:
    55. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb08  61f35018  
    56. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb0c  4017a64d  /system/lib/libc.so
    57. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb10  00010000  
    58. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb14  6aa7ca40  
    59. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb18  6aa75814  /data/app-lib/com.me.myunitygame-2/libunity.so
    60. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb1c  6aa7ca40  
    61. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb20  6afdfc78  
    62. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb24  40175f51  /system/lib/libc.so (memalign+12)
    63. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb28  6aa53598  /data/app-lib/com.me.myunitygame-2/libunity.so
    64. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb2c  69e9c52c  /data/app-lib/com.me.myunitygame-2/libunity.so (MemoryManager::LowLevelAllocate(unsigned int)+20)
    65. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb30  00010000  
    66. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb34  69ea0330  /data/app-lib/com.me.myunitygame-2/libunity.so (StackAllocator::StackAllocator(int, char const*)+60)
    67. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb38  00010000  
    68. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb3c  00000000  
    69. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb40  df0027ad  
    70. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb44  00000000  
    71. 01-13 15:02:08.651: I/DEBUG(18579):     #00  6afdfb48  6a899854  /data/app-lib/com.me.myunitygame-2/libunity.so
    72. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb4c  000002b9  
    73. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb50  00000000  
    74. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb54  6ab7835c  
    75. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb58  000013ac  
    76. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb5c  00000007  
    77. 01-13 15:02:08.651: I/DEBUG(18579):          6afdfb60  40bc3fbc  
    78. 01-13 15:02:08.661: I/DEBUG(18579):          6afdfb64  6a06c460  /data/app-lib/com.me.myunitygame-2/libunity.so (RuntimeInitialize()+52)
    79. 01-13 15:02:08.661: I/DEBUG(18579):     #01  6afdfb68  6aa699fc  /data/app-lib/com.me.myunitygame-2/libunity.so
    80. 01-13 15:02:08.661: I/DEBUG(18579):          6afdfb6c  6a1e3620  /data/app-lib/com.me.myunitygame-2/libunity.so (UnityInitApplication()+12)
    81. 01-13 15:02:08.661: I/DEBUG(18579):     #02  6afdfb70  00000000  
    82. '41a7de20 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    83. 01-13 15:02:08.851: E/InputDispatcher(478): channel '41a7de20 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    84. 01-13 15:02:08.871: W/InputDispatcher(478): channel '419b2398 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    85. 01-13 15:02:08.871: E/InputDispatcher(478): channel '419b2398 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    86. 01-13 15:02:08.891: D/Zygote(126): Process 18601 terminated by signal (11)
    87. 01-13 15:02:08.921: D/dalvikvm(478): GC_FOR_ALLOC freed 1796K, 19% free 18301K/22348K, paused 91ms, total 93ms
    88. 01-13 15:02:08.921: W/InputDispatcher(478): Attempted to unregister already unregistered input channel '419b2398 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)'
    89. 01-13 15:02:08.921: I/WindowState(478): WIN DEATH: Window{419b2398 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    90. 01-13 15:02:08.921: I/ActivityManager(478): Process com.me.myunitygame (pid 18601) has died.
    91. 01-13 15:02:08.921: W/WindowManager(478): Force-removing child win Window{419bf288 u0 SurfaceView} from container Window{419b2398 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    92. 01-13 15:02:08.921: W/ActivityManager(478): Force removing ActivityRecord{4187b388 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}: app died, no saved state
    93. 01-13 15:02:08.941: W/WindowManager(478): Failed looking up window
    94. 01-13 15:02:08.941: W/WindowManager(478): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@41f51718 does not exist
    95. 01-13 15:02:08.941: W/WindowManager(478):   at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8102)
    96. 01-13 15:02:08.941: W/WindowManager(478):   at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8093)
    97. 01-13 15:02:08.941: W/WindowManager(478):   at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:932)
    98. 01-13 15:02:08.941: W/WindowManager(478):   at android.os.BinderProxy.sendDeathNotice(Binder.java:433)
    99. 01-13 15:02:08.941: W/WindowManager(478):   at dalvik.system.NativeStart.run(Native Method)
    100. 01-13 15:02:08.941: I/WindowState(478): WIN DEATH: null
    101. 01-13 15:02:08.941: I/WindowState(478): WIN DEATH: Window{41b00a70 u0 SurfaceView}
    102. 01-13 15:02:08.941: W/InputDispatcher(478): Attempted to unregister already unregistered input channel '41a7de20 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity (server)'
    103. 01-13 15:02:08.941: I/WindowState(478): WIN DEATH: Window{41a7de20 u0 com.me.myunitygame/com.unity3d.player.UnityPlayerNativeActivity}
    104. 01-13 15:02:08.991: W/InputMethodManagerService(478): Got RemoteException sending setActive(false) notification to pid 18601 uid 10094
    105.  
     
  8. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Something is definitely wrong here. First of all the reason it crashes is that it is trying to create two instances of unity within the same process - that will never work. The activity attribute android:launchMode="singleTask" should ensure there is only one Unity activity active within a process. The other option would be if the first activity actually gets destroyed without calling UnityPlayer.quit(). If that happens none of the native resources will be released.

    I think you need to file a bug report and attach your project for me to be able to figure out exactly what is going on.
     
  9. Kukuruz

    Kukuruz

    Joined:
    Jan 8, 2014
    Posts:
    7

    I can confirm that the player is not releasing the native resources. When I close the app, no "Unregistering JNI method..." occurs( as it usually does when app is closing without problems).

    However, I will file a bug report asap. Thank you for your time.
     
  10. cxtcxt2005

    cxtcxt2005

    Joined:
    Jan 14, 2015
    Posts:
    1
    hi,guys.I met the same problem today...so,if the problem got resolved ? Thank you so much :)
     
  11. dongbo

    dongbo

    Joined:
    Mar 28, 2015
    Posts:
    3
    i have same too, is there any solution ?
     
  12. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    @Kukuruz we had run into a (perhaps?) similar issue, where if the player will close the game and then launch it immediately back again, the game would crash on startup.

    I even remember opening a bug for it (case 667260).

    The issue is that Unity is dumping some resources (cleaning up) when you close the game, but it's not really closed just yet. When you launch it at that point again, it crashes.

    There was never a fix from Unity for our case, so we just had to work around it by not calling Application.Quit(). i can't recall the exact workaround we pulled but i'll have to look it up if you're interested.