Skip to content

Fix stop() off the main thread leaving the frame callback running - #2

Merged
imayankkumar merged 1 commit into
mainfrom
maint/FP-001-stop-off-main-thread
Oct 31, 2026
Merged

imayankkumar merged 1 commit into
mainfrom
maint/FP-001-stop-off-main-thread

Conversation

@imayankkumar

@imayankkumar imayankkumar commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner
  • Fix: stop() off the main thread no longer leaves the frame callback running
  • New: tests for stop() called off the main thread
  • Update: README, KDoc and FRAME_MONITOR docs state that stop() is main-thread only

FrameMonitorImpl.stop() set the state to STOPPED and then called
FrameSource.stop(). ChoreographerFrameSource.stop() throws on the wrong
thread before it removes its frame callback, so an off-main-thread
session.stop() left the session reporting stopped while the callback
kept re-posting every vsync. A retry of stop() returned early because
the state was no longer STARTED, so the callback could never be removed.

stop() now checks the calling thread before any state change. Off the
main thread it throws IllegalStateException and leaves the session
running, so the caller can still stop it from the main thread. Stopping
an idle or stopped session stays a no-op on any thread.

Adds regression tests and documents the contract in FramePulseSession,
README and docs/FRAME_MONITOR.md.
@imayankkumar imayankkumar changed the title fix: reject off-main-thread stop() before changing session state Fix stop() off the main thread leaving the frame callback running Oct 31, 2026
@imayankkumar
imayankkumar merged commit 23e6e74 into main Oct 31, 2026
2 checks passed
@imayankkumar
imayankkumar deleted the maint/FP-001-stop-off-main-thread branch October 31, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant