ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
488 stars 567 forks source link

Browser tab auto-closing right after calling Browser.open() #2095

Open Alekey1919 opened 2 months ago

Alekey1919 commented 2 months ago

Bug Report

Opening a new browser after arriving at the app through a deep link causes it to auto-close or crash.

Plugin(s)

"@capacitor/browser": "^6.0.0" (Although I tried downgrading and the problem persisted)

Capacitor Version

  Capacitor Doctor   

Latest Dependencies:

  @capacitor/cli: 6.0.0
  @capacitor/core: 6.0.0
  @capacitor/android: 6.0.0
  @capacitor/ios: 6.0.0

Installed Dependencies:

  @capacitor/android: 6.0.0
  @capacitor/core: 6.0.0
  @capacitor/cli: 6.0.0
  @capacitor/ios: 6.0.0

[success] Android looking great! 👌
[error] Xcode is not installed

Platform(s)

Android 14

Current Behavior

In our app, users need to go to the browser to register and that works fine, the issue is that after registering they go back to the app and the browser closes as expected, but when we trigger another Browser.open() inside the app the tab opens and closes immediately.

Expected Behavior

The browser should stay opened until closed by the user.

Code Reproduction

const handleRedirect = async () => {
    await Browser.open({
      url: '...',
      windowName: '_self',
      presentationStyle: 'popover',
    })
  }

useEffect(() => {
  handleRedirect()
}, [])

Other Technical Details

Opening a new browser alone works fine, but doing so after arriving at the app through a deep link doesn’t. Also, I'm not calling Browser.close() anywhere in the code.

Additional Context

The only workaround I found so that the browser doesn't close automatically was to call Browser.open() inside a setTimeout with at least 1500ms, and even with that it's still not consistent.

IT-MikeS commented 2 months ago

For your reproduction please include a sample app repo that can be tested against

Ionitron commented 2 months ago

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙