fix: prevent funbox reactivation during page transition to leaderboards (@d1rshan)#7871
fix: prevent funbox reactivation during page transition to leaderboards (@d1rshan)#7871d1rshan wants to merge 5 commits intomonkeytypegame:masterfrom
Conversation
|
This actually looks really cool lol, maybe we can add a setting to make funboxes apply globally. |
|
yea that would be cool for some effects, i don't know if you watched the vid till the end coz it wouldn't be a good idea for all the funboxes. |
The user could always turn off that setting if they don't want funboxes to apply to the rest of the website. Maybe even have a list of all the funboxes the user wants to have globally applied. |
yess that sounds like a good idea :) i'll see what i can do for "global funboxes" in a new pr coz that doesn't come under the scope of this bug fix, i'm thinking we can just keep a single toggle control like you said (but without the specific list control for now): what do you think? |
Let's wait for feedback from miodec or fehmer before starting any work. I'll open a discussion for that (#7874).
Not sure what you mean by "valid" funboxes, I think that global switch should apply to every funbox (although some won't have a visible effect because they're word generation related). Otherwise sounds good! |
yeah ofc 👍
by valid, i mean funboxes that visibly affect the ui without breaking it |
|
I am pretty sure the funboxes were cleared when leaving the test page at some point. Maybe you can bisect the change which broke this. I don't think we should add a setting to activate some funboxes on all pages or just test page, very niche use-case. For the CRT funbox we added special handling to apply on all pages. |
Yes the funboxes are still being cleared, the bug is an edge case where they get reapplied. NOTE:
IssueThe issue is that when leaving the test page, In this edge case, that allowed That is why it did not happen on every navigation, but could show up after moving between routes multiple times. FixThe fix was to keep the existing test page reset, but make that specific teardown restart skip |
okay, understood.
yes, CRT funbox is intentional and it is handling it properly to be applied globally and this PR doesn't affect existing CRT behavior |
|
This is the commit adding this bug: |
Thanks, i was kind of mislead by assuming the bug always existed but went unnoticeable. it looks like 765ca95 exposed the bug. i found the same timing pattern on:
just to confirm, do you want me to address the fix close to the regression point or keep my current fix which addresses the teardown directly? |
|
Can you reproduce the same error when switching from test to account or friends page with funbox mirror active? For me only the switch to the leaderboard does not clear the funbox css. I think it would be good to find the reason first why this is only broken for the transition to the leaderboard page, than decide how to fix it. |
|
ohh yes, weirdly the css is leaking only for leaderboard and other pages are getting the leaked css only after navigating from leaderboard page (this is what happened at the end of the vid) i'll manually look into it and will try to figure out the exact reason |
|
@fehmer, i figured out the exact issue, so the flow now is:
and also since leaderboard doesn't bother about cleaning "funbox css" after we move to other pages from leaderboard, the css remains and other pages get affected. |
There was a problem hiding this comment.
Pull request overview
Fixes a route-transition issue where exiting the test page could re-run test initialization and re-activate funboxes, leaking funbox global effects (e.g., mirror, space_balls) onto other pages.
Changes:
- Add
skipInitoption toTestLogic.restart()to allow teardown without callinginit(). - Use
skipInit: truewhen the test page hides to prevent funbox reactivation during page transitions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/ts/test/test-logic.ts | Adds skipInit to restart() and conditionally bypasses init() during restart completion. |
| frontend/src/ts/pages/test.ts | Calls restart({ noAnim: true, skipInit: true }) on afterHide to avoid reinitialization when leaving the test page. |
| TestState.setPaceRepeat(repeatWithPace); | ||
| TestInitFailed.hide(); | ||
| TestState.setTestInitSuccess(true); | ||
|
|
||
| if (options.skipInit) { | ||
| TestState.setTestRestarting(false); | ||
| return; | ||
| } |
|
hey @fehmer, i updated the fix to a cleaner approach. let me know if you'd like any changes
|
Bug
bug.mp4
Cause
When navigating from the test page to leaderboards, the leaderboard's sync loading delays
setActivePagefrom firing. During this window,init()checksgetActivePage() === "test"which still returns"test"sincesetActivePagehasn't fired yet, causing funboxes to be incorrectly reactivated.Fix
Added a new
isTestPageVisiblesignal that is set tofalseimmediately after the test page finishes hiding (before sync loading starts) and back totrueafter sync loading completes when navigating to test.init()now checksisTestPageVisible()instead ofgetActivePage() === "test"to determine whether to activate funboxes.