fix(replay): Allow STARTED -> RESUMED state transition in ReplayLifecycle#5213
Closed
fix(replay): Allow STARTED -> RESUMED state transition in ReplayLifecycle#5213
Conversation
…ycle The ReplayLifecycle state machine did not allow transitioning from STARTED to RESUMED. This caused a bug when the app returned to foreground after being in background longer than sessionIntervalMillis: 1. Timer fires -> stop() -> state becomes STOPPED 2. App returns to foreground -> start() -> state becomes STARTED 3. resume() fails because STARTED -> RESUMED was not allowed The fix adds RESUMED as a valid transition from the STARTED state. Co-authored-by: Giancarlo Buenaflor <giancarlobuenaflor97@gmail.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Fixes
- Allow STARTED -> RESUMED state transition in ReplayLifecycle ([#5213](https://github.com/getsentry/sentry-java/pull/5213))If none of the above apply, you can opt out of this check by adding |
Sentry Build Distribution
|
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.
📜 Description
Fix a bug in the
ReplayLifecyclestate machine where theSTARTED -> RESUMEDtransition was not allowed. This caused the replay to not properly resume after the app returned to foreground following a session timeout in the background.💡 Motivation and Context
When the app goes to background for longer than
sessionIntervalMillis:replayController.stop()→ state becomesSTOPPEDLifecycleWatcher.startSession()callsreplayController.start()→ state becomesSTARTEDreplayController.resume()→ this failed because the state machine did not allowSTARTED → RESUMEDThe recording still partially worked through the root view listener path (which triggers
onConfigurationChanged), but the lifecycle state was incorrect (stuck atSTARTEDinstead ofRESUMED), andcaptureStrategy.resume()/recorder.resume()were never called.The fix adds
RESUMEDas a valid transition from theSTARTEDstate inReplayLifecycle.💚 How did you test it?
ReplayLifecycleTestto verifySTARTED -> RESUMEDis now allowedafter stop, start and resume restarts replayinReplayIntegrationTestthat verifies the full stop → start → resume flow works correctlyLifecycleWatcherTest,ReplayLifecycleTest, andReplayIntegrationTest— all pass📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps