capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Proposed fix for #2072 - EventGroup count variable should allowed to be zero

Open cornflakes opened this issue 1 year ago • 2 comments

This would in turn fix: https://github.com/ionic-team/capacitor-plugins/issues/2072

This pull request addresses a bug introduced in commit e2cdf3538b9741c5ec394abb14516ceaf5e12d43 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.

This 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().

cornflakes avatar Jun 06 '24 11:06 cornflakes

Anyway we can get this merged?

aagavin avatar Jan 21 '25 16:01 aagavin

@jcesarmobile Would it be possible to get this merged?

cornflakes avatar Feb 14 '25 07:02 cornflakes