Proposed fix for #2072 - EventGroup count variable should allowed to be zero #2125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This would in turn fix:
#2072
This pull request addresses a bug 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.
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().