playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.47k stars 966 forks source link

Application.Quit () makes it unstable on Android #310

Closed grayger closed 9 years ago

grayger commented 9 years ago

When Application.Quit () is called on back key, the game finished normally. But trying to execute the app again makes it crash after 5~10 seconds' waiting with black screen.

The log during the waiting is as below: 12-12 17:59:02.918: V/GamesNativeSDK(3686): Received Activity Stop Event. 12-12 17:59:02.958: V/GamesNativeSDK(3686): Attached to JVM on thread main_dispatch 12-12 17:59:02.958: V/GamesNativeSDK(3686): Running disconnect operation. 12-12 17:59:08.023: V/GamesNativeSDK(3686): Detaching from JVM on thread main_dispatch

and just after the crash, executing the app again is OK.

device: Galaxy Note plugin version: GooglePlayGamesPlugin-0.9.10 unity: 4.5.5f1 mac

Do you have any idea? Shouldn't I use Application.Quit() or is there any way to release GamesNativeSDK on quitting?

abalta commented 9 years ago

I have a same issue but I do not know google play games plugin caused that.

grayger commented 9 years ago

Without activating the GPS, it did not happen. Plugin ver 0.9.7 also has no problem as far as I tested.

GameDrill commented 9 years ago

Same issue here. Everything works fine but whenever the application is quitting it crashes.

Following lines are causing the error,

Social.localUser.Authenticate((bool success) => { authenticated = success; });

also tried with the following,

GooglePlayGames.PlayGamesPlatform.Instance.Authenticate ((bool success) => { authenticated = success; });

ToddKerpelman commented 9 years ago

Tracking internally as 18766114

sayeed360 commented 9 years ago

I am having the same issue. Game crashes or takes 4-5 seconds to close. Please solve this ASAP.

GameDrill commented 9 years ago

I had same problem. But I downgraded the plugin to version 0.9.07. It is working fine in my game Chips Factory https://play.google.com/store/apps/details?id=com.gamedrill.ChipsFactory

On Wed, Dec 31, 2014 at 8:09 PM, sayeed360 notifications@github.com wrote:

I am having the same issue. Game crashes or takes 4-5 seconds to close. Please solve this ASAP.

— Reply to this email directly or view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/310#issuecomment-68445206 .

sayeed360 commented 9 years ago

is it compatible with new unity 4.6.1f1 ?

sayeed360 commented 9 years ago

integrating 0.9.07 with unity 4.6.1f1 produces a lot more errors. its not a good solution. thanks anyways.

GameDrill commented 9 years ago

Did you removed previous plugin completely?

vector-8 commented 9 years ago

Same problem here using this plug-in in combination with unityads http://unityads.unity3d.com
Game takes 4-8 seconds to close and (sometimes) to load the next scene.

hippogamesunity commented 9 years ago

Same problem. Sometimes ANR. Resolve ASAP please)

simsis3d commented 9 years ago

I was having freezing(around 10-12 second) problem on application quit. Then a clever guy recommended a solution like removing PlayerProxyActivity from AndroidManifest file. Then I did it. Then my problem was transformed to your problem. Application freezes for around 5-6 second on application start. Described here https://github.com/playgameservices/play-games-plugin-for-unity/issues/370

rdaros commented 9 years ago

Ctrl-Z

On Tue, Jan 27, 2015 at 1:10 PM, Hakan Ozcan notifications@github.com wrote:

I was having freezing(around 10-12 second) problem on application quit. Then a clever guy recommended a solution like removing PlayerProxyActivity from AndroidManifest file. Then I did it. Then my problem was transformed to your problem. Application freezes for around 5-6 second on application start. Described here #370 https://github.com/playgameservices/play-games-plugin-for-unity/issues/370

— Reply to this email directly or view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/310#issuecomment-71663037 .

sayeed360 commented 9 years ago

Okay 0.9.07 definitely works . no issues at all

hippogamesunity commented 9 years ago

@sayeed360 0.9.07 does not support SavedGames. For achievements and leaderboards - you can use it.

andreiciceu commented 9 years ago

I'm having ghe same problem here...

hippogamesunity commented 9 years ago

Hi! Not fixed in 0.912 (((((((((((((((((((((((

Gamya commented 9 years ago

I think I found a workaround that seems to work: http://gamya-games.blogspot.com.es/2015/02/problems-with-google-play-plugin-for.html

hippogamesunity commented 9 years ago

@Gamya Thanks! I wonder this issue is still not fixed around 2 month

claywilkinson commented 9 years ago

We're looking into it - stay tuned....

ajnaduvil commented 9 years ago

@Gamya : can u please give some idea how to create that simple android plugin in unity?

Gamya commented 9 years ago

I posted a reply in the comments section of the blog.

I think it's a bit confusing because it's difficult to explain with detail in a comment. I'm going to make a mini-tutorial, but for now you can check out that comment to see if it helps.

ajnaduvil commented 9 years ago

@Gamya : Thank u so much for the help. I have integrated it in a small game i made. It works for me well :)

hippogamesunity commented 9 years ago

@Gamya can you upload your plugin? Thanks!

hippogamesunity commented 9 years ago

Fixed in ver 15?

IvyKun commented 9 years ago

Still not fixed on 0.9.15...

Same as https://github.com/playgameservices/play-games-plugin-for-unity/issues/424 and https://github.com/playgameservices/play-games-plugin-for-unity/issues/398.

It makes the plugin kind of useless, I don't want my app to crash just for this.

I'm gonna try the workaround @Gamya suggested and report back.

IvyKun commented 9 years ago

Reading about @Gamya approach I ended up doing the same but without the plugin. It's not a solution, closing is not the same as moving to back, but well, it works as a workaround.

Just call this instead of Application.Quit.

private void CustomApplicationQuit() {

if UNITY_ANDROID

        using (AndroidJavaClass javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            AndroidJavaObject unityActivity = javaClass.GetStatic<AndroidJavaObject>("currentActivity");
            unityActivity.Call<bool>("moveTaskToBack", true);
        }
    #else
        Application.Quit();
    #endif
}
Piflik commented 9 years ago

Little correction to @IvyKun's last comment: I had to specify the type argument for 'GetStatic' and the return type for 'Call'. Other than that, this workaround works like a charm, at least at first glance. Note that this doesn't exit the application, but sends it to the background, like the home button would. Calling 'finish' instead of 'moveTaskToBack' would exit, but has the exact same behaviour as Application.Quit

private void CustomApplicationQuit() {
#if UNITY_ANDROID
    using (AndroidJavaClass javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
        AndroidJavaObject unityActivity = javaClass.GetStatic<AndroidJavaObject>("currentActivity");
        unityActivity.Call<bool>("moveTaskToBack", true);
    }
#else
    Application.Quit();
#endif
}
ahsyarif008 commented 9 years ago

i cannot use the code @IvyKun and @Piflik. there is something error on """"AndroidJavaObject unityActivity = javaClass.GetStatic("currentActivity"); """"" when i try to run game there is error log on it.

Piflik commented 9 years ago

@ahsyarif008 Apparently this board ignores stuff between 'less than' and 'grater than' smbols in text that is not marked as code...hadn't even noticed that my code was missing the exact same stuff I had to add to @IvyKun's until now...

Anyway, i updated my last post, it should be working now.

IvyKun commented 9 years ago

Wow, thanks @Piflik because I didn't noticed either. My code is the same that the one in @Piflik post. I'm using it right now in a few games and works good.

staythirsty90 commented 9 years ago

Hello,

I'm experiencing the issue as well. Using 0.9.20

claywilkinson commented 9 years ago

Looks like this had a Unity bug also. According to their Release Notes, Version 5.0.2 fixes this issue.

staythirsty90 commented 9 years ago

Unfortunately the issue is still present, at least for me :(

claywilkinson commented 9 years ago

That is too bad. Can you file a bug with Unity? http://issuetracker.unity3d.com/

GameDrill commented 9 years ago

The issue is not closed. It's close because of duplicate. The issue is still opened.

On Wed, Jun 3, 2015 at 5:25 AM, Clayton Wilkinson notifications@github.com wrote:

Closed #310 https://github.com/playgameservices/play-games-plugin-for-unity/issues/310 .

— Reply to this email directly or view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/310#event-320613713 .

claywilkinson commented 9 years ago

@GameDrill - I understand that Application.Quit() is causing problems. Can you provide a log? Since Unity is aware of the issue, I am skeptical that it is specific to this plugin. If you think otherwise, please help me understand where you think the problem is and re-open the issue.

GameDrill commented 9 years ago

I am also finding the solution. For now I have downgraded the Unity GPG plugin version 0.9.02 which works. Also, there are lot of features pending in UnityGPG. e.g. LoadScore function is just a placeholder. I think they are waiting to someone else from community to contribute. It will be now nearly 8-9 months this issue is pending.

On Wed, Jun 3, 2015 at 9:00 PM, Clayton Wilkinson notifications@github.com wrote:

@GameDrill https://github.com/GameDrill - I understand that Application.Quit() is causing problems. Can you provide a log? Since Unity is aware of the issue, I am skeptical that it is specific to this plugin. If you think otherwise, please help me understand where you think the problem is and re-open the issue.

— Reply to this email directly or view it on GitHub https://github.com/playgameservices/play-games-plugin-for-unity/issues/310#issuecomment-108485408 .

kyuskoj commented 9 years ago

this issue is still present... I've wasted my time for 2 days..

Eanshine commented 8 years ago

I still meet the question now,Unity version is 5.4.3,gpg version is latest new .I used the method of "moveTaskToBack";

ArmandCloud commented 8 years ago

Same here. Unity 5.3.5 p1 + Plugin 0.9.34. //This is normal quit when i just silent sign in.

05-29 15:42:38.140 32355-32355/com.guya.dragracingproclutch I/Unity: onPause 05-29 15:42:38.240 32355-458/com.guya.dragracingproclutch D/Unity: Setting up 1 worker threads for Enlighten. 05-29 15:42:38.240 32355-459/com.guya.dragracingproclutch D/Unity: Thread -> id: 841b5ad0 -> priority: 1 05-29 15:42:38.450 32355-32384/com.guya.dragracingproclutch D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcess:IL 05-29 15:42:38.450 32355-32384/com.guya.dragracingproclutch D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodGetInfo:II 05-29 15:42:38.450 32355-32384/com.guya.dragracingproclutch D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcessMicData:ILI 05-29 15:42:42.144 32355-32355/com.guya.dragracingproclutch W/Unity: Timeout while trying to pause the Unity Engine. 05-29 15:42:42.154 32355-32355/com.guya.dragracingproclutch I/Choreographer: Skipped 240 frames! The application may be doing too much work on its main thread. 05-29 15:42:42.154 32355-32355/com.guya.dragracingproclutch I/Unity: windowFocusChanged: false 05-29 15:42:42.154 32355-32355/com.guya.dragracingproclutch V/GamesNativeSDK: Received Activity Stop Event. 05-29 15:42:42.164 32355-553/com.guya.dragracingproclutch V/GamesNativeSDK: Attached to JVM on thread main_dispatch 05-29 15:42:42.164 32355-553/com.guya.dragracingproclutch V/GamesNativeSDK: Running disconnect operation. 05-29 15:42:46.157 32355-32355/com.guya.dragracingproclutch I/Unity: onDestroy 05-29 15:42:46.167 32355-32355/com.guya.dragracingproclutch D/Unity: [EGL] Attaching window :0x0 05-29 15:42:46.177 32355-32355/com.guya.dragracingproclutch I/Process: Sending signal. PID: 32355 SIG: 9

//This is CRASHED quit when i silent sign in + initialize nearby.

05-29 15:45:49.917 749-749/com.guya.dragracingproclutch I/Unity: onPause 05-29 15:45:50.007 749-1502/com.guya.dragracingproclutch D/Unity: Setting up 1 worker threads for Enlighten. 05-29 15:45:50.017 749-1503/com.guya.dragracingproclutch D/Unity: Thread -> id: 83ae0a10 -> priority: 1 05-29 15:45:50.227 749-808/com.guya.dragracingproclutch D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcess:IL 05-29 15:45:50.227 749-808/com.guya.dragracingproclutch D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodGetInfo:II 05-29 15:45:50.227 749-808/com.guya.dragracingproclutch D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcessMicData:ILI 05-29 15:45:53.921 749-749/com.guya.dragracingproclutch W/Unity: Timeout while trying to pause the Unity Engine. 05-29 15:45:53.921 749-749/com.guya.dragracingproclutch I/Choreographer: Skipped 240 frames! The application may be doing too much work on its main thread. 05-29 15:45:53.921 749-749/com.guya.dragracingproclutch I/Unity: windowFocusChanged: false 05-29 15:45:53.931 749-749/com.guya.dragracingproclutch V/GamesNativeSDK: Received Activity Stop Event. 05-29 15:45:53.931 749-749/com.guya.dragracingproclutch V/GamesNativeSDK: NearbyConnections client disconnected. 05-29 15:45:53.931 749-1629/com.guya.dragracingproclutch V/GamesNativeSDK: Attached to JVM on thread main_dispatch 05-29 15:45:53.931 749-1629/com.guya.dragracingproclutch V/GamesNativeSDK: Running disconnect operation. 05-29 15:45:53.931 749-808/com.guya.dragracingproclutch A/libc: Fatal signal 11 (SIGSEGV) at 0x83ebe9d8 (code=1), thread 808 (main)

//This is normal quit of unity empty project

05-29 15:47:15.260 1715-1715/com.asd.asd I/Unity: onPause 05-29 15:47:15.270 1715-2182/com.asd.asd D/Unity: Setting up 1 worker threads for Enlighten. 05-29 15:47:15.270 1715-2183/com.asd.asd D/Unity: Thread -> id: 81adc5b0 -> priority: 1 05-29 15:47:15.300 1715-1732/com.asd.asd D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcess:IL 05-29 15:47:15.300 1715-1732/com.asd.asd D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodGetInfo:II 05-29 15:47:15.300 1715-1732/com.asd.asd D/dalvikvm: Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcessMicData:ILI 05-29 15:47:15.450 1715-1732/com.asd.asd D/Unity: Waiting for finish 05-29 15:47:15.500 1715-1732/com.asd.asd D/Unity: ASensorManager_destroyEventQueue returned 0 05-29 15:47:15.510 1715-1732/com.asd.asd I/Unity: ##unity-automation:{"messageType":"MemoryLeaks","allocatedMemory":18947,"memoryLabels":[{"NewDelete":18172},{"Manager":72},{"String":131},{"ScriptManager":496},{"SceneManager":76}]} 05-29 15:47:15.560 1715-1715/com.asd.asd I/Unity: windowFocusChanged: false 05-29 15:47:15.720 1715-1715/com.asd.asd D/Unity: [EGL] Attaching window :0x0 05-29 15:47:16.181 1715-1732/com.asd.asd D/v_gal: [tid=1732] TLS is not valid if _TLSDestructor is called before. 05-29 15:47:16.181 1715-1715/com.asd.asd I/Unity: onDestroy 05-29 15:47:16.201 1715-1715/com.asd.asd I/Process: Sending signal. PID: 1715 SIG: 9

I am not a professional programmer but i think Some how GamesNativeSDK doing some job when unity call onPause. In first log, I say "normal quit" because it doesn't crash when not initialize nearby, but it shows same symptoms.

Regards,

AnilThapliyal08 commented 7 years ago

Can use :

System.Diagnostics.Process.GetCurrentProcess().Kill(); // instead of //Application.Quit();

DoofahSoftware commented 5 years ago

Can use :

System.Diagnostics.Process.GetCurrentProcess().Kill(); // instead of //Application.Quit();

This fixed the timeout messages for me.