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 add a new BROWSER_CLOSED event #2072

Open
kurtiev opened this issue Apr 3, 2024 · 2 comments
Open

@capacitor/browser add a new BROWSER_CLOSED event #2072

kurtiev opened this issue Apr 3, 2024 · 2 comments
Labels
platform: android type: bug A confirmed bug report

Comments

@kurtiev
Copy link

kurtiev commented Apr 3, 2024

Feature Request

Plugin

@capacitor/browser

Description

This is probably feature-request and bug issue as well :)
I faced with problem when browser window is minimized (not closed) and event browserFinished Is triggered.
I need to know when is was closed, not minimized. Take a look the attached screenshot, it has "minimize" control.

Platform(s)

Android only.

Preferred Solution

Add one more event here BROWSER_CLOSED or don't trigger BROWSER_FINISHED while inappbrowser is minimized.

Alternatives

Additional Context

IMG_2111

@ionitron-bot ionitron-bot bot added the triage label Apr 3, 2024
@kurtiev kurtiev changed the title @capacitor/browser add BROWSER_CLOSED event @capacitor/browser add a new BROWSER_CLOSED event Apr 3, 2024
@ionitron-bot ionitron-bot bot removed the triage label Apr 3, 2024
@IT-MikeS IT-MikeS added the type: bug A confirmed bug report label Apr 10, 2024
Copy link

ionitron-bot bot commented Apr 10, 2024

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@cornflakes
Copy link
Contributor

The PR: #2125 would in turn fix this bug.

This bug is introduced in commit e2cdf35 by @ItsChaceD on January 22nd, 2024.

The issue arises because the URL is opened from an activity instead of the plugin itself. This causes the unbindService method (called from handleOnPause in the plugin) to be invoked before the open method (called from the activity callback). This results in group.enter() being called before group.reset(). Consequently, when group.leave() is triggered from the TAB_HIDDEN navigation event, the browserEventListener.onBrowserEvent(BROWSER_FINISHED) event fires incorrectly when the app goes into the background.

The pull request fixes the bug by changing the count threshold from count <= 0 to count < 0, preventing the unintended firing of the BROWSER_FINISHED event.

While the order of calls remains unchanged, modifying the count threshold achieves the same outcome of ensuring group.reset() happens before group.leave().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android type: bug A confirmed bug report
Projects
None yet
Development

No branches or pull requests

4 participants