Fix closeOverlay() hanging forever when overlay isn't running - #183
Open
mtranchi wants to merge 2 commits into
Open
Fix closeOverlay() hanging forever when overlay isn't running#183mtranchi wants to merge 2 commits into
mtranchi wants to merge 2 commits into
Conversation
result.success/error was never called in the branch where OverlayService isn't currently running, leaving the Dart-side awaited Future pending indefinitely. Adds an else branch so the method channel call always resolves. Fixes X-SLAYER#182
…active onStartCommand's "already running, recreate view" branch called stopSelf() before falling through to recreate and re-add the view. stopSelf() only schedules a stop, it doesn't return immediately, so execution continued, successfully re-added a new view, and then shortly after Android processed the pending stop and destroyed the whole service (including the just-added view) via onDestroy(). Net effect: calling showOverlay() a second time while already showing makes the overlay flash briefly visible, then disappear for good. Removes the stray stopSelf() call — recreating the view in place shouldn't stop the service at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Two separate bugs, both in overlay service lifecycle handling:
Fixes closeOverlay() hangs forever when overlay isn't currently running #182 — `closeOverlay`'s handler only calls `result.success(true)` inside the `if (OverlayService.isRunning)` branch. When the overlay isn't currently running, execution falls through to `return` without ever calling `result.success`/`result.error`, leaving the Dart-side `await FlutterOverlayWindow.closeOverlay()` pending forever.
Fixes showOverlay() called while already active tears the whole service down moments later #184 — `onStartCommand`'s "already running" branch calls `stopSelf()` before falling through to recreate and re-add the view. `stopSelf()` only schedules a stop rather than returning immediately, so a new view gets added successfully, then Android processes the pending stop shortly after and tears the whole service down via `onDestroy()`. Calling `showOverlay()` a second time while already showing makes the overlay flash visible, then disappear for good.
Changes
Testing
Verified against a real device (Samsung Galaxy A36) for both fixes.