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

@capacitor/browser: window is not closing properly #2045

Open
Badisi opened this issue Feb 28, 2024 · 7 comments
Open

@capacitor/browser: window is not closing properly #2045

Badisi opened this issue Feb 28, 2024 · 7 comments

Comments

@Badisi
Copy link

Badisi commented Feb 28, 2024

Bug Report

Plugin(s)

@capacitor/[email protected]

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

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

Platform(s)

Android

Current Behavior

When opening and closing a browser on Android, the browser sometimes seems to get stuck.
As we can see in the video below, a browser is opened programmatically from the app then closed manually.
The issue is that the closing is failing randomly, leaving the app unresponsive.

We can see the first time the window is closed, that a black bar is sliding from the top of the app to the bottom.
And when the closing is failing (ie. the second time), the top bar suddenly changes to black and stays there.
Like if the window was still there, but transparent, on top of the app view, and thus not allowing to interact with it.
We can also see that once we move the app to the background then foreground, the black top bar disappears and the app is responsive again.

41.mov

Expected Behavior

Browser window should always close without issue.

@Badisi
Copy link
Author

Badisi commented Feb 29, 2024

I traced down the issue to this reproducible snippet:

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

The root cause is when you try to close the browser while it is already closed or being closed.

@Ionitron
Copy link
Collaborator

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 💙

@dyonng
Copy link

dyonng commented Mar 20, 2024

I'm running into the same problem where the Browser doesn't fully close and I'm left with the status bar and action bar still on the screen, just like in @Badisi's video. However, I don't have a Browser.close() call in my callback and I'm still running into the same issue:

const handle = await Browser.addListener("browserFinished", async () => {
    this.doSomeCoolStuff();
    await handle.remove();
});
await Browser.open({ url });

My app is running in landscape, and my test device is portrait rotation-locked, so when the Browser opens, it rotates back to portrait. And when I close the Browser, it switches back to landscape and then the bug occurs with the stuck status bar and action bar. HOWEVER, if I disable the device's portrait rotation-lock, the Browser will open in landscape to match the current orientation, and this time, when I close the Browser, everything works perfectly.

Not sure why this happens. And I don't think there's currently a way to set the orientation of the Browser.

Plugin(s)

@capacitor/[email protected]

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

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

Platform(s)

Android

My test devices are:
Pixel 2 XL - Android 11
Pixel 7 Pro - Android 14

@tibimunteanu
Copy link

I am having the same issue where the Browser doesn't close when pressing X, but leaves behind a black header and transparent body. I have to manually tap Back to close it and be able to interact with the app again.

I am not doing any manual closing or anything.
All I'm doing is
Browser.open({ url });

I have the app locked in Landscape mode. I don't know if that is relevant.

@functora
Copy link

functora commented Aug 2, 2024

I am having the same issue where the Browser doesn't close when pressing X, but leaves behind a black header and transparent body. I have to manually tap Back to close it and be able to interact with the app again.

I am not doing any manual closing or anything. All I'm doing is Browser.open({ url });

I have the app locked in Landscape mode. I don't know if that is relevant.

I have exactly the same issue, but it is reproduced only on weaker android device. On fast phone it runs ok.

@AleksandrMatuka
Copy link

AleksandrMatuka commented Oct 22, 2024

@Ionitron
I confirm that this still exists on Android devices after exiting landscape mode. The overlay remains and blocks the app from being used. Tricks like Browser.close won’t help here because it’s already effectively closed.

Steps to reproduce:
1)Set up Capacitor 6 ( any version ) + React on any Android device ( Pixel 8 for example )
2)Open the internal browser using Capacitor.open.
3)Rotate the phone to landscape mode.
4)Press the back button

Please use the three-button navigation mode instead of gesture mode to reproduce this issue, as it allows for pressing the back button

@AntoscencoVladimir
Copy link

Same here ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants