Skip to content

Sign out first then sign in causes android app crash. #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GarlicDipping opened this issue Oct 27, 2018 · 15 comments
Open

Sign out first then sign in causes android app crash. #68

GarlicDipping opened this issue Oct 27, 2018 · 15 comments

Comments

@GarlicDipping
Copy link

GarlicDipping commented Oct 27, 2018

From the sample code, it seems like when I sign out first, theConfiguration becomes null and when I sign in after, it stays null and causes app crash.

So I've wrapped and exposed GoogleSignIn_Configure method in GoogleSignInImpl class, and when configuration changes, call it and problem gone.

I took a quick look at native code and seems like it would cause not much problem(anyway it keeps calling CallConfigure() on every signin-out action), But I'd like to double check if It't ok to do.

Here's code for my modified Configuration accessor in GoogleSignIn.cs :

public static GoogleSignInConfiguration Configuration
{
    set
    {
        // Can set the configuration until the singleton is created.
        if (theInstance == null || theConfiguration == value || theConfiguration == null)
        {
            if(theInstance != null && theConfiguration == null)
            {
                //From sign out, Instance stays non-null but theConfiguration is null.
                //Needs configuration refresh.
                theInstance.impl.Configure(value);
            }
            theConfiguration = value;
        }
        else
        {
            throw new SignInException(GoogleSignInStatusCode.DeveloperError,
                "DefaultInstance already created. " +
                " Cannot change configuration after creation.");
        }
    }

    get
    {
        return theConfiguration;
    }
}
@dustinkerstein
Copy link

Is this the error you're getting?

02-06 12:03:35.342 16651-16676/? E/CRASH: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'google/marlin/marlin:9/PQ1A.190105.004/5148680:user/release-keys'
    Revision: '0'
    pid: 16651, tid: 16676, name: UnityMain  >>> com.MomentCaptureInc.PanoMoments <<<
        r0 00000000  r1 d0bf2190  r2 e0cd6014  r3 e938db88
        r4 ccf5bc10  r5 d0bf25d4  r6 00000000  r7 d0bf24c8
        r8 c94c9880  r9 00000000  sl c4336cc0  fp d0bf2180
        ip c3edf583  sp d0bf2180  lr e0cd6024  pc c3edf584  cpsr 0000000b
    backtrace:
02-06 12:03:35.578 16651-16676/? E/CRASH: 	#00  pc 00008584  /data/app/com.MomentCaptureInc.PanoMoments-KNWjnhVRt7zvcNaw2pwm0g==/lib/arm/libnative-googlesignin.so (GoogleSignIn_Pending+1)
    	#01  pc 0000d020   ( (wrapper managed-to-native) Google.Impl.GoogleSignInImpl:GoogleSignIn_Pending (System.Runtime.InteropServices.HandleRef) + 0x48 (0xe0cd5fd8 0xe0cd6060) [0xe9a1aee0 - Unity Root Domain]+53280)
    	#02  il ........  at (wrapper managed-to-native) Google.Impl.GoogleSignInImpl.GoogleSignIn_Pending (System.Runtime.InteropServices.HandleRef) <0xffffffff>
    	#03  il 0000002c  at Google.Impl.NativeFuture.get_Pending () <0x0002c>
    	#04  il 00000047  at Google.Future`1<object>.get_Pending () <0x00047>
    	#05  il 0000001f  at Google.Future`1/<WaitForResult>c__Iterator0<object>.<>m__0 () <0x0001f>
    	#06  il 00000027  at UnityEngine.WaitUntil.get_keepWaiting () <0x00027>
    	#07  il 00000027  at UnityEngine.CustomYieldInstruction.MoveNext () <0x00027>
    	#08  il 00000067  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator,intptr) <0x00067>
    	#09  il 0000007b  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object_intptr (object,intptr,intptr,intptr) <0x0007b>
    	#10  il ........  at (wrapper managed-to-native) UnityEngine.MonoBehaviour.StartCoroutine_Auto_Internal (System.Collections.IEnumerator) <0xffffffff>
    	#11  il 00000024  at UnityEngine.MonoBehaviour.StartCoroutine (System.Collections.IEnumerator) <0x00024>
    	#12  il 0000007f  at Google.GoogleSignIn.SignIn () <0x0007f>
    	#13  il 0000005b  at CanvasController_LoginSignUp.onSignIn () <0x0005b>
    	#14  il 0000003b  at UnityEngine.Events.InvokableCall.Invoke () <0x0003b>
    	#15  il 0000009b  at UnityEngine.Events.UnityEvent.Invoke () <0x0009b>
    	#16  il 00000063  at UnityEngine.UI.Button.Press () <0x00063>
    	#17  il 00000033  at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData) <0x00033>
    	#18  il 00000043  at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler,UnityEngine.EventSystems.BaseEventData) <0x00043>
    	#19  il 000001e3  at UnityEngine.EventSystems.ExecuteEvents.Execute<object> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<object>) <0x001e3>
    	#20  il 000003a3  at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData,bool,bool) <0x003a3>
    	#21  il 0000013b  at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () <0x0013b>
    	#22  il 000000a7  at UnityEngine.EventSystems.StandaloneInputModule.Process () <0x000a7>
02-06 12:03:35.579 16651-16676/? E/CRASH: 	#23  il 0000018b  at UnityEngine.EventSystems.EventSystem.Update () <0x0018b>
    	#24  il 0000006b  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0x0006b>
02-06 12:03:35.583 16651-16676/? E/CRASH: 	#02  pc 0087dcd4  /data/app/com.MomentCaptureInc.PanoMoments-KNWjnhVRt7zvcNaw2pwm0g==/lib/arm/libunity.so
    	#03  pc 0072b1a4  /data/app/com.MomentCaptureInc.PanoMoments-KNWjnhVRt7zvcNaw2pwm0g==/lib/arm/libunity.so
    	#04  pc 004e1e80  /data/app/com.MomentCaptureInc.PanoMoments-KNWjnhVRt7zvcNaw2pwm0g==/lib/arm/libunity.so
    	#05  pc 0070795c  /data/app/com.MomentCaptureInc.PanoMoments-KNWjnhVRt7zvcNaw2pwm0g==/lib/arm/libunity.so
    	#06  pc 002dea50  /data/app/com.MomentCaptureInc.PanoMoments-KNWjnhVRt7zvcNaw2pwm0g==/lib/arm/libunity.so
    code around pc:
        c3edf564 bdb04620 46204605 eb40f7ff f0164628   F...F F..@.(F..
        c3edf574 6800fcb7 bcaef017 f0176800 6800bcb3  ...h.....h.....h
        c3edf584 69096801 00004708 466fb580 68016800  .h.i.G....oF.h.h
        c3edf594 47886889 28123001 2009bf84 4902bd80  .h.G.0.(... ...I
        c3edf5a4 f8514479 bd800020 0001c258 af02b5b0  yDQ. ...X.......
        c3edf5b4 68284605 68c96801 b1d04788 68016828  .F(h.h.h.G..(h.h
        c3edf5c4 478868c9 b1a06800 f7ff2004 4604eb04  .h.G.h... .....F
        c3edf5d4 68016828 478868c9 60206800 eb6cf7ff  (h.h.h.G.h `..l.
02-06 12:03:35.587 16651-16676/? E/MessageQueue: IdleHandler threw exception
    java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
    Build fingerprint: 'google/marlin/marlin:9/PQ1A.190105.004/5148680:user/release-keys'
    Revision: '0'
    pid: 16651, tid: 16676, name: UnityMain  >>> com.MomentCaptureInc.PanoMoments <<<
        r0 00000000  r1 d0bf2190  r2 e0cd6014  r3 e938db88
        r4 ccf5bc10  r5 d0bf25d4  r6 00000000  r7 d0bf24c8
        r8 c94c9880  r9 00000000  sl c4336cc0  fp d0bf2180
        ip c3edf583  sp d0bf2180  lr e0cd6024  pc c3edf584  cpsr 0000000b
    
        at libnative-googlesignin.GoogleSignIn_Pending(GoogleSignIn_Pending:1)
        at Unknown.0000d020(Unknown Source:0)
        at GoogleSignInImpl.GoogleSignIn_Pending(Native Method)
        at NativeFuture.get_Pending(<0x0002c>:44)
        at Future`1.get_Pending(<0x00047>:71)
        at <WaitForResult>c__Iterator0.<>m__0(<0x0001f>:31)
        at WaitUntil.get_keepWaiting(<0x00027>:39)
        at CustomYieldInstruction.MoveNext(<0x00027>:39)
        at SetupCoroutine.InvokeMoveNext(<0x00067>:103)
        at <Module>.runtime_invoke_void_object_intptr(Native Method)
        at MonoBehaviour.StartCoroutine_Auto_Internal(Native Method)
        at MonoBehaviour.StartCoroutine(<0x00024>:36)
        at GoogleSignIn.SignIn(<0x0007f>:127)
        at CanvasController_LoginSignUp.onSignIn(<0x0005b>:91)
        at InvokableCall.Invoke(<0x0003b>:59)
        at UnityEvent.Invoke(<0x0009b>:155)
        at Button.Press(<0x00063>:99)
        at Button.OnPointerClick(<0x00033>:51)
        at ExecuteEvents.Execute(<0x00043>:67)
        at ExecuteEvents.Execute(<0x001e3>:483)
        at StandaloneInputModule.ProcessTouchPress(<0x003a3>:931)
        at StandaloneInputModule.ProcessTouchEvents(<0x0013b>:315)
        at StandaloneInputModule.Process(<0x000a7>:167)
        at EventSystem.Update(<0x0018b>:395)
        at Object.runtime_invoke_void__this__(Native Method)
        at libmono.00022543(Native Method)
        at libmono.mono_runtime_invoke(mono_runtime_invoke:136)
        at libunity.0087dcd4(Native Method)
        at libunity.0072b1a4(Native Method)
        at libunity.004e1e80(Native Method)
        at libunity.0070795c(Native Method)
        at libunity.002dea50(Native Method)

I'm also seeing something similar on iOS.

@dustinkerstein
Copy link

Also, would you be able to provide your complete workaround? Thanks!

wrapped and exposed GoogleSignIn_Configure method in GoogleSignInImpl class, and when configuration changes, call it and problem gone.

@GarlicDipping
Copy link
Author

Hi, sorry for the late reply. It's quite a long time ago I fixed this myself so I'm not sure if the error message is same as yours, but yeah, I can share the workaround.

So as I noted, the problem is that when you sign out first then try sign in, 'theConfiguration' variable in GoogleSignIn.cs class becomes null and causes error.

So you need to edit GoogleSignInImpl.cs first. Extract constructor logic of GoogleSignInImpl class to a method :

internal GoogleSignInImpl(GoogleSignInConfiguration configuration)
		: base(GoogleSignIn_Create(GetPlayerActivity()))
{
	Configure(configuration);
}

public void Configure(GoogleSignInConfiguration configuration)
{
	if (configuration != null)
	{
		List<string> scopes = new List<string>();
		if (configuration.AdditionalScopes != null)
		{
			scopes.AddRange(configuration.AdditionalScopes);
		}
		GoogleSignIn_Configure(SelfPtr(), configuration.UseGameSignIn,
						configuration.WebClientId,
						configuration.RequestAuthCode,
						configuration.ForceTokenRefresh,
						configuration.RequestEmail,
						configuration.RequestIdToken,
						configuration.HidePopups,
						scopes.ToArray(),
						scopes.Count,
						configuration.AccountName);
	}
}

then you can use my modified GoogleSignIn.cs code above, I think. :)

@dustinkerstein
Copy link

Thanks @GarlicDipping! That seems to have fixed my error on both iOS and Android. I did have to add void Configure (GoogleSignInConfiguration configuration) to internal interface ISignInImpl:

image

But then things seemed to work perfectly. This definitely appears to be a bit of a bug, so hopefully it gets fixed at some point.

@rahuloftheramaneffect
Copy link

@GarlicDipping - Thank you so much for posting your solution! It worked perfectly for me, too!
I really hope they add this fix to the master branch, although I'm not sure anyone is actually maintaining this repo anymore.

@nvtuan96
Copy link

Thanks you alot

@bhupiister
Copy link

@GarlicDipping Thanks a lot mate, I still cannot believe that it has not been added to the master branch.
@dustinkerstein Thanks to you too, void configuration has to be added at the bottom for it to work.

To make it simple for other people to understand, I will add both scripts here.

GoogleSignIn.cs

https://gist.github.com/bhupiister/72f894df9ff6ad03ac7dfa0ebfcb8d20

GoogleSignInImpl.cs

https://gist.github.com/bhupiister/c329c33ae6a217f34193728d93a3e7d9

@Hugo-Pereira
Copy link

Hugo-Pereira commented Aug 18, 2020

@bhupiister links don't work :)
I created a gist with the corrections mentioned:
https://gist.github.com/Hugo-Pereira/e5298b53c25e493fd7917e0837c0506c
You'll find both files there.

Thanks guys!

@jt7785
Copy link

jt7785 commented Aug 10, 2021

This is a bit old, but for me it is still relevant.
I was wondering, wouldn't adding theInstance = null to the signout method solve the issue as well?

public void SignOut() {
      theConfiguration = null;
      theInstance = null;    // this is the new line
      impl.SignOut();
    }

@Serveladik
Copy link

Thanks, its ok, but after i was logged in and sign out, then sign in again. It logged in Silently, without account choosing, but next signout and sign in are okay
Why?

@felixcary
Copy link

Thanks, its ok, but after i was logged in and sign out, then sign in again. It logged in Silently, without account choosing, but next signout and sign in are okay Why?

@Hugo-Pereira I have the same issues, can you help us? thank you

@Hugo-Pereira
Copy link

Sorry, I'm no longer using this plugin.

@Serveladik
Copy link

Serveladik commented Oct 11, 2022 via email

@LagField
Copy link

LagField commented Nov 9, 2023

This is a bit old, but for me it is still relevant. I was wondering, wouldn't adding theInstance = null to the signout method solve the issue as well?

public void SignOut() {
      theConfiguration = null;
      theInstance = null;    // this is the new line
      impl.SignOut();
    }

It'll solve the problem, too

@xiongtoto0526
Copy link

This is a bit old, but for me it is still relevant. I was wondering, wouldn't adding theInstance = null to the signout method solve the issue as well?

public void SignOut() {
      theConfiguration = null;
      theInstance = null;    // this is the new line
      impl.SignOut();
    }

best answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests