fix(menu): handle spectate requests during transition state gracefully#1109
Open
YgorLeal wants to merge 1 commit into
Open
fix(menu): handle spectate requests during transition state gracefully#1109YgorLeal wants to merge 1 commit into
YgorLeal wants to merge 1 commit into
Conversation
citizenfx#1084) When rapidly cycling through spectated players, a new spectate request could arrive while the previous transition was still in progress. The old code called stopSpectating() + error(), causing a script error and black screen. Now the handler waits up to 5 seconds for the ongoing transition to complete before proceeding. If it times out, it shows a user-friendly error message instead of crashing.
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
Fixes #1084 — Spectate no longer crashes with a script error when rapidly cycling through players.
Problem
When quickly pressing up/down arrows to cycle spectated players, a new
txcl:spectate:startevent could arrive while the previous transition (screen fade, collision loading) was still in progress. The handler calledstopSpectating()followed byerror(), which produced:This left the player with a black screen or broke spectate entirely.
Solution
Instead of erroring immediately, the handler now waits up to 5 seconds (100 attempts x 50ms) for the ongoing transition to complete. If the transition finishes in time, the new spectate request proceeds normally. If it times out, a user-friendly snackbar error is shown instead of a script crash.
Testing