I've only tested the issue on Android.
The sign in works fine when the app starts. But after you log in , log out and reload for several times . The signIn() doesn't return anything. You fire another signIn() and it throws this error:
In Progress error: Error: cannot set promise - some async operation is still in progress.
From now on, you can't get any data from signIn() anymore unless you kill the app and start the app, but the problem never goes away as you reload the apps again for several times. You can go as many as 5 reloads without a problem (Sometimes as few as 1 reload), but the issue will eventually occur.
Related issue: https://github.com/react-native-community/react-native-google-signin/issues/475
https://github.com/stonecold123/signin-test
To run the app:
Update the Android SDK directory in ./android/local.properties
Create a new Android app in the firebase console and name it as com.signin.test
Add your debug keystore's SHA1 value to the console, and download google-services.json to android/app
Add your web client ID in src/TestScreen.jsx
The signIn() should return data even after multiple reloads.
I suspect the signIn() is stuck and never gets resolved when the app reloads.
Please provide the version of your
Platform: Android
"dependencies": {
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-firebase": "^4.3.8",
"react-native-google-signin": "^1.0.0-rc3",
"react-native-navigation": "^2.0.2477"
},
'com.android.tools.build:gradle:3.1.3'
'com.google.gms:google-services:3.2.1'
I'm seeing the same issue. (Again.)
At this point I guess this is just an annoyance during debugging. But I'm nervous that CodePush reloads may also trigger this problem when we try to update our bundle post-deployment.
I know that the maintainers have looked at this before and couldn't reproduce it or track it down. But I'm wondering if there is a way to build something into the API to allow client code to flush or cancel existing requests, or something. Even if it's ugly.
Hello and thanks for reporting. I wasn't able to reproduce this with the provided repo. What I tried was logging in and out and then reloading for several times, repeatedly, with 5 - 10 reloads. Signing in worked even after doing that.
If I am to fix this, I will need very detailed reproduction instructions (eg. include an emulator that you use). Alternatively, I'd suggest that people seeing this issue do some debugging to find where the problem is.
I just spent a few hours tracing this. Here's what I've observed, not that it necessarily makes a huge amount of sense.
At points I was able to get this to happen quite reliably. My app calls signInSilently when it starts, and at times it would only take a few reload cycles for that to fail and everything to get wedged. Subsequent JS reloads don't fix the problem, as I suspect that they don't reset the native modules. Reinstalling the app is a reliable fix to the problem.
After adding logging throughout the Android portions of this library, what I observed is that the AccessTokenRetrievalTask seems to be the source of the problem. When either signIn or signInSilently fail to resolve their promises, it is because that task never completes.
What is extremely strange is that when this happens I can still see logs from the constructor and from the onPreExecute method, but doInBackground and onPostExecute never seem to run. Or at least, I don't see logs when they run. I _do_ see logs when they do run, and as long as doInBackground runs everything seems happy and no hangs are observed. Inspecting the system logs from around the time of the hang doesn't turn up anything either.
It's worth noting that onPreExecute (and onPostExecute) are run on the UI thread, while doInBackground is moved to a background thread. So I wonder if something about React Native reloading breaks the background thread periodically, although this doesn't seem to happen reliably.
Again, none of this makes much sense to me. FWIW it does look like the AsyncTask approach was added post version 0.11, which was working reliably for me before.
To me this seems very much like a race condition both in that it's hard to reproduce and it seems to come and go somewhat randomly based on external factors. For example, I had it breaking fairly reliably for an hour or two—which was great since it helped me make some progress tracing it. But then I plugged my laptop in and now I can't reproduce it reliably anymore, which could be because Apple was throttling my laptop previously because the battery was low and there's some kind of timing bug at play (given that the bundle gets rebuilt on each reload during development). That's also why I don't have more detailed logs—sorry.
I'm at the point where I need this to work reliably for an app release in a week. So this is kind of giving me the heebie jeebies. Can @vonovak or another maintainer comment on what would be lost by rolling back to 0.11? I did not experience these issues using that release.
@gchallen thanks for the information!
Subsequent JS reloads don't fix the problem, as I suspect that they don't reset the native modules.
I think that JS reloads do reset the modules, but it's true the AsyncTask introduces some trickery.
What is extremely strange is that when this happens I can still see logs from the constructor and from the onPreExecute method, but doInBackground and onPostExecute never seem to run. Or at least, I don't see logs when they run. I do see logs when they do run, and as long as doInBackground runs everything seems happy and no hangs are observed. Inspecting the system logs from around the time of the hang doesn't turn up anything either.
Okay, so some quick googling suggests we can try this - can you see if that improves things for you @gchallen and @stonecold123 ? Alternatively we'll use threads / AsyncTaskLoader instead of AsyncTask.
Thanks @vonovak. FWIW I'm on Pie, so I don't know if that's relevant to me. But the next time I get back to poking at this I'll give it a try. Thanks for your help.
Has anyone found any solution or a work around for this problem. I am facing this issue.
I'm awaiting signinSilently method and the code sometimes doesnt finish the task
p.s I also tried the stackoverflow solution suggested by @vonovak. But it didn't resolve the issue
My solution is to use rc-1. I'll let a maintainer comment on why that's a problem. For me it's working reliable on a Nexus 5 running Marshmallow and a Google Pixel running Pie, as well as a iPhone SE running iOS 11.4.
FWIW, the native Android code seemed to go through a fairly serious rewrite even between rc-1 and rc-2, and then (IIRC) was modified even further for rc-3. I'm not really sure why or what the changes were intended to accomplish.
Do you guys happen to use react-native-navigation or react-native-firebase?
@gchallen I switched to rc-1 but the problem still persists. After a couple of reloads it doesnt proceed after RNGooglesignin.signinsilently. I'm using a simulator with android P.
@stonecold123 We are not using either of those.
@ganesh-pprasad
The last working version is 0.11 for me.
I'm also keeping a close eye to this issue https://github.com/react-native-community/react-native-google-signin/issues/489, which also throws the Sign-in in progress error.
This issue is resolved for me after using the rc-1 rc-3 and applied the @vonovak 's suggestion to use this this solution for AsyncTask
@ganesh-pprasad are you using RC-1 or RC-3? There is no AsyncTask in RC-1 so using task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); with RC-1 makes no sense actually.
I am using RC-3. oops!
@stonecold123 I'm using react-native-firebase with the RC-3 without any hiccups. both signIn and signInSilently work for me even after countless reloads.
Yes,I just did what @ganesh-pprasad did.
I haven't come across any error after changing the source code in RNGoogleSignInModule:
````
private void handleSignInTaskResult(Task
try {
GoogleSignInAccount account = result.getResult(ApiException.class);
WritableMap params = getUserProperties(account);
//new AccessTokenRetrievalTask(this).execute(params);
new AccessTokenRetrievalTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,params);
} catch (ApiException e) {
int code = e.getStatusCode();
promiseWrapper.reject(String.valueOf(code), GoogleSignInStatusCodes.getStatusCodeString(code));
}
}
```
@jozan, @vonovak Would you consider usingexecuteOnExecutor` in the next version?
@stonecold123 We will concider executeOnExecutor. Thanks for confirming that it works for you! 👍
potentially related to sdk version and other stuff, see similar issue and the solution https://github.com/react-native-community/react-native-google-signin/issues/522#issuecomment-421849859
@vonovak it's not work for me...
This problem can be easily reproduced on simulator (Pixel 2L API 27). Here are some logs:
Error: cannot set promise - some async operation is still in progress
at createErrorFromErrorData (NativeModules.js:146)
at NativeModules.js:95
at MessageQueue.__invokeCallback (MessageQueue.js:397)
at MessageQueue.js:127
at MessageQueue.__guard (MessageQueue.js:297)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
at t (RNDebuggerWorker.js:1)
potentially related to sdk version and other stuff, see similar issue and the solution #522 (comment)
Can still reproduce this bug under the API 28 SDK on API 27 simulator, it's probably not the cause.
@kigawas great to see somebody can reproduce it. Please try this branch https://github.com/react-native-community/react-native-google-signin/pull/533 - that should help tracking it down.
PRs are welcome, but please discuss possible solution first
We had this issue in our app, and a colleague of mine found the issue. Posting it here, before I send PR for you guys.
Our MainActivity.java looked like this (relevant parts).
public class MainActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Setup react root view.
mReactInstanceManager = getReactNativeHost().getReactInstanceManager();
mReactRootView = new ReactRootView(this);
mReactRootView.startReactApplication(mReactInstanceManager, getMainComponentName(), null);
setContentView(mReactRootView);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Notify the facebook sdk of the activity result.
MainApplication.getCallbackManager().onActivityResult(
requestCode,
resultCode,
data
);
}
Then in de onActivityResult you see super being called, but that is not enough to trigger the instance manager event. We still need to call onActivityResult on the mReactInstanceManager we created.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
...
// --- ADD THIS ---
if (mReactInstanceManager != null) {
mReactInstanceManager.onActivityResult(this, requestCode, resultCode, data);
}
}
Now I think we added some non-standard code to get other parts of the app working, but assuming people add Google Signin, they also add Facebook Login and overwriting the onActivityResult on their MainActivity.java file. I also did a quick Google and see some boilerplates using the ReactInstanceManager.
Hope this helps some people out. Let me know so I can add it to the Android guide with a PR
@RuudBurger thanks for investigating, so is this a brownfield app that you're building? PR for the docs would be appreciated!
Not brownfield, but we needed some stuff that needed the "include react native inside existing app" code (Chromecast support for existing platform).
I see the signin-test also extends the instancemanager, but does a different check here https://github.com/wix/react-native-navigation/blob/22b3b40d3a0941271a66238098cfb02a03deef75/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java#L101-L107 so that might not always trigger
I'm seeing the issue but the promise hangs consistently (sign in promise never resolves).
Building against both SDK 27 and SDK 28 made no difference.
I'm also using expokit to run the application if it makes any difference. Here is a link to the source code (requires expo start running at the same time as build/running the application to successfully load the code, also note this code is on the 'detach' branch):
https://github.com/benkaiser/stretto-mobile-next/tree/detach
I just updated to react native 0.57 and google-sign-in to 1.07. Changing execute to executeOnExecutor in handleSignInTaskResult() still works.
happening to me as well
still persists, no matter which version I choose and edit this executeOnExecutor, GoogleSignin.signIn() doesn't resolve or catch any errors. With the demo example app it works, it seems that there is some task on the background of my app (and other people's apps too).
Any idea how to fix it?
The problem has gone away for now. I don't even need to modify the source code in react-native-google-signin. I removed implementation "com.google.android.gms:play-services-auth:xxx from the dependencies. I also updated the react-native-firebase dependencies.
implementation project(':react-native-google-signin')
implementation project(':react-native-firebase')
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation ('com.google.android.gms:play-services-base:16.0.1')
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
transitive = true
}
implementation(project(':react-native-google-signin')) {
exclude group: "com.google.android.gms" // very important
}
@vforvasile this issue unfortunately does not have an easy repro, so the maintainers cannot fix it. If you can reproduce it, it would be greatly appreciated if you could find the fix and open a PR for this. Thanks.
@laukaichung following your lead, upgrading dependencies seems to have fixed the issue for me.
compile ('com.google.android.gms:play-services-auth:16.0.1') {
force = true
}
compile ('com.google.android.gms:play-services-base:16.0.1') {
force = true
}
// Upgrading specifically to 16.0.6 here seemed to do the trick.
compile ('com.google.firebase:firebase-core:16.0.6') {
force = true
}
There is a fix for a race condition issue in #623. If you still get signIn() to stuck please report here.
upgrading to 1.2.1 fixed this issue for me.
I've only recently started using this library. I'm using 1.2.1 and get this issue when awaiting GoogleSignin.signIn(). The promise never resolves and calling it again throws the error. After reinstalling my app, everything works as intended for a while and then randomly breaks again. This is using an emulator (Nexus 5x API 28 x86, Android 9, API 28). I haven't tried it in any other environment yet.
I use com.google.gms:google-services:4.1.0 and com.android.tools.build:gradle:3.3.1. I use firebase-core:16.0.7 as well if that's relevant.
I have react native 0.58.6, react 16.8.3, and react-native-google-signin 1.2.1. I verified that version 1.2.1 is really installed by checking the node_modules/react-native-google-signin/package.json and checking the version in there.
I cannot reliably reproduce it. It works fine after an app reinstall. At some point it will fail and from that point on, it will keep failing until I reinstall. I tried looking for something that causes it to fail (live reloading, setting breakpoints, just waiting etc) but couldn't pinpoint it to anything.
Can you try building a production APK and try to repro the issue with it?
I’m using almost the same setup and never had any problems so this is quite
interesting. Also quite hard to fix without reliable repro case.
On Tue, 12 Mar 2019 at 17.28, Burak notifications@github.com wrote:
I've only recently started using this library. I'm using 1.2.1 and get
this issue when awaiting GoogleSignin.signIn(). The promise never resolves
and calling it again throws the error. After reinstalling my app,
everything works as intended for a while and then randomly breaks again.
This is using an emulator (Nexus 5x API 28 x86, Android 9, API 28). I
haven't tried it in any other environment yet.I use com.google.gms:google-services:4.1.0 and
com.android.tools.build:gradle:3.3.1. I use firebase-core:16.0.7 as well if
that's relevant.I have react native 0.58.6, react 16.8.3, and react-native-google-signin
1.2.1. I verified that version 1.2.1 is really installed by checking the
node_modules/react-native-google-signin/package.json and checking the
version in there.I cannot reliably reproduce it. It works fine after an app reinstall. At
some point it will fail and from that point on, it will keep failing until
I reinstall. I tried looking for something that causes it to fail (live
reloading, setting breakpoints, just waiting etc) but couldn't pinpoint it
to anything.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/react-native-community/react-native-google-signin/issues/485#issuecomment-472045665,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAXsqVfpCoZVOVeYnQi4OnQJ6yV76g5Xks5vV8eegaJpZM4WAz_R
.
I haven't done that yet, but I also haven't had the issue return again since my previous message. It's understandably hard to fix without a repro case. I'll try to do some more investigation next time it happens.
The issue still appears for me
Both production and dev
1.2.1 version
@tereshchenkoartyom94 (or anybody else experiencing the issue) please consider figuring out what is wrong and contributing a fix, thanks! :)
Noticed something today with this problem that might be of use in diagnosing. I installed the new 2.0.0 version and have been updating my code to use getTokens() to get the access token. This call also hangs in the same manner as signIn() and signInSilently()
Error message when double calling getTokens():
Possible Unhandled Promise Rejection (id: 0):
Error: Cannot set promise. You've called "getTokensAsync" while "getTokensAsync" is already in progress and has not completed yet. Make sure you're not repeatedly calling signInSilently and signIn from your JS code while the previous call has not completed yet.
Think it's worth opening this a separate issue?
@booleanBoy the error message is is correct - you have called "getTokensAsync" while "getTokensAsync" is already in progress and that will lead to a promise rejection. The first call should not hang though. Feel free to open a separate issue to discuss.
Updated RN to "0.59.8", now this error happens every time I try to login
Google sign in is working perfectly in android. But in iOS, it's redirectiong to google.com. Even after I login to my google account in that google.com page, it is still not navigating back to my app and logging me into the app. Could any one please tell a solution?
There is a fix for a race condition issue in #623. If you still get
signIn()to stuck please report here.
I still have this problem, when I try to execute GoogleSignin.signIn() I enter my personal data and the app gets stuck on the call, until I press anywhere on the screen so that the request gets cancelled.
react-native: 0.58.1
react-native-google-signin: 2.0.0
firebase-core: 16.0.6
play-services-auth:16.0.0
play-services-base:16.0.1
I am also facing the same issue. signIn() doesn't return anything.
Can anybody help please?
Facing the same issue. signIn() return anything.
"react-native": "0.61.2",
"@react-native-community/google-signin": "^3.0.2",
we made a big change to promise logic in v4 https://github.com/react-native-community/google-signin/releases/tag/v4.0.0
errors like the one reported will not happen any more, so I'll close this. Please open new issues if you encounter something buggy.
Most helpful comment
happening to me as well