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

[BUG] App freezes when dismissing android browser #41

Closed
1 task done
ms-emp opened this issue Feb 27, 2024 · 9 comments
Closed
1 task done

[BUG] App freezes when dismissing android browser #41

ms-emp opened this issue Feb 27, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@ms-emp
Copy link
Contributor

ms-emp commented Feb 27, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Library version

latest

Description

When running on Android and the user dismisses the login window (by clicking the X button), the app becomes unresponsive.

It happens more with the angular library.

It looks like there are two browser windows open, if you click the device back button we can see another window fading down and then the app is responsive again.

Steps to reproduce

  1. clone the repo
  2. run the start:android:demo-ngx-auth script
  3. click Login
  4. dismiss the browser window
  5. try to click Login again
  6. if it works, dismiss the browser and repeat
  7. at some point the app will become unresponsive

If you minimize the app and then bring it back to the foreground it will work again.

Environment

  • OS Name:
  • System Model Name:
  • npm:
  • Node.js:
@ms-emp ms-emp added bug Something isn't working needs triage labels Feb 27, 2024
@Badisi
Copy link
Owner

Badisi commented Feb 28, 2024

This issue seems related to @capacitor/browser.

By default this is the plugin used on mobile to open a web view and navigate to the identity provider.
This web view is opened in a separate native window, which means it is out of our control.
Same applies when closing the window in step 4: we are closing it manually (not programmatically).
So it all happens in the native/capacitor context (not in our app context).

I have opened an issue in the Capacitor repo : ionic-team/capacitor-plugins#2045
with detailed explanations and a video.

@Badisi
Copy link
Owner

Badisi commented Feb 28, 2024

Worth mentioning here that I'm also planning on releasing a cordova/capacitor plugin to better follow Apple's recommendations.

Currently @capacitor/browser is using SFSafariViewController instead of SFAuthenticationSession (iOS11) and ASWebAuthenticationSession (iOS12+). Not only it does not follow the security guideline but it also not allow SSO to work, as SFSafariViewController does not share cookies outside the app.

@ms-emp
Copy link
Contributor Author

ms-emp commented Feb 28, 2024

This issue seems related to @capacitor/browser.

By default this is the plugin used on mobile to open a web view and navigate to the identity provider. This web view is opened in a separate native window, which means it is out of our control. Same applies when closing the window in step 4: we are closing it manually (not programmatically). So it all happens in the native/capacitor context (not in our app context).

I have opened an issue in the Capacitor repo : ionic-team/capacitor-plugins#2045 with detailed explanations and a video.

But when I try to use the browser plugin directly (for example: Browser.open({ url: 'http://capacitorjs.com/' })) it never happens?!

@Badisi Badisi self-assigned this Feb 29, 2024
@Badisi
Copy link
Owner

Badisi commented Feb 29, 2024

@ms-emp, I traced the issue down to something like:

await Browser.addListener(
  'browserFinished',
  (): void => void Browser.close())
);
await Browser.open({ url: 'http://capacitorjs.com/' });

Sounds like the issue is when we are trying to close the browser when it is actually closed or being closed.
Fun fact: the doc says it should be a no-op for Android.

Can you please confirm this scenario is also failing on your side ?

@ms-emp
Copy link
Contributor Author

ms-emp commented Feb 29, 2024

@Badisi

You are right, Browser.close() is causing the issue, so probably we shouldn't call it on Android.

But why do you call it anyway? Isn't 'browserFinished' fired when the user has already closed the browser?

@Badisi Badisi closed this as completed in 6c238b1 Mar 1, 2024
@ms-emp
Copy link
Contributor Author

ms-emp commented Mar 1, 2024

@Badisi

When do you plan to release the latest version?

@Badisi
Copy link
Owner

Badisi commented Mar 1, 2024

Hopefully this week-end, or next Monday (still have a few issues to fix).

@Badisi
Copy link
Owner

Badisi commented Mar 7, 2024

🎉 Released in @badisi/[email protected] 📦🚀

@Badisi
Copy link
Owner

Badisi commented Mar 7, 2024

🎉 Released in @badisi/[email protected] 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants