-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[web-browser] Fix issue when the browser is dismissed quickly #28452
Conversation
The Pull Request introduced fingerprint changes against the base commit: 1eccf32 Fingerprint diff[
{
"type": "dir",
"filePath": "../../packages/expo-web-browser/ios",
"reasons": [
"expoAutolinkingIos"
],
"hash": "a3689bd1cb825a8e26e2dbcf70f27cc04e525209"
}
] Generated by PR labeler 🤖 |
@@ -169,25 +167,11 @@ export async function openBrowserAsync( | |||
throw new UnavailabilityError('WebBrowser', 'openBrowserAsync'); | |||
} | |||
|
|||
if (browserLocked) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to remove on Android?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android uses intents, it always navigates away from the app so it had no guards anyway. It's not possible to call it twice. I think this was aimed at iOS specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did just notice one issue, dismissBrowser
shouldn't be called on android.
Why
Closes #27197
Opening and dismissing the browser quickly causes the delegates not to be called. This leaves the module in a state where it can no longer be used because it thinks there is still an active browser session.
How
We were controlling locking the api from the JS side. This needs the delegates to be called to resolve the promise. We can't rely on the delegates being called but we can know if we have presented the view controller. I've added a check if the controller has been presented. If it has when
openBrowserAsync
has been called we can assume that it was called and dismissed quickly and set the session tonil
.Test Plan
Tested in bare-expo, rapidly opening and closing the browser. Everything seems to be working fine. Seen as we recreate the session, there's no risk of resolving the same promise twice.