Skip to content
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

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

alanjhughes
Copy link
Collaborator

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 to nil.

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.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 25, 2024
@expo-bot
Copy link
Collaborator

expo-bot commented Apr 25, 2024

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 🤖

@alanjhughes alanjhughes marked this pull request as ready for review April 25, 2024 12:59
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Apr 25, 2024
@@ -169,25 +167,11 @@ export async function openBrowserAsync(
throw new UnavailabilityError('WebBrowser', 'openBrowserAsync');
}

if (browserLocked) {
Copy link
Member

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?

Copy link
Collaborator Author

@alanjhughes alanjhughes Apr 29, 2024

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.

Copy link
Collaborator Author

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.

@alanjhughes alanjhughes merged commit 1dac64d into main Apr 29, 2024
10 of 11 checks passed
@alanjhughes alanjhughes deleted the @alanhughes/web-browser-dimiss-fix branch April 29, 2024 13:11
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expo WebBrowser on iOS fails to open after closing a page sheet browser too quickly
4 participants