-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUGFIX: Running scripts may be loaded before main UI #1726
base: dev
Are you sure you want to change the base?
BUGFIX: Running scripts may be loaded before main UI #1726
Conversation
This fixes a bug, so if push comes to shove I'll accept it. However, this is only fixing it for the specific case of script loading, it's not fixing the root of the issue. For instance, this won't fix the game (sometimes) crashing at load, or our tests flaking. Edit: What I'm hoping for is a way for the router to actually be initialized before everything, in some guaranteed deterministic fashion. |
In the latest commit, I add a queue that stores router actions when the main UI is not loaded. That queue will be processed after the main UI is loaded. This change should fix those crashes that happen because the router is used before the initialization. How to test it:
|
FWIW, I haven't (completely) forgotten about this. I want to do a deep dive on the code in question, and that hasn't worked out so far. |
…nning-scripts-may-be-loaded-before-main-ui # Conflicts: # src/ui/GameRoot.tsx
…aded-before-main-ui # Conflicts: # src/NetscriptWorker.ts
…aded-before-main-ui # Conflicts: # src/NetscriptWorker.ts
When we load running scripts, those scripts may run before the main UI is loaded. In that case, anything that interacts with the router will fail to run. For example, Singularity APIs that call
Router.toPage()
will throw an error, and that error may not be shown to the player because the main UI is not loaded.How to reproduce:
If you cannot reproduce it consistently, you can forcefully delay the main UI: In
src\ui\LoadingScreen.tsx
, add another promise (e.g.,new Promise((resolve) => setTimeout(resolve, 1000))
) to[initSwc(), Engine.load(saveData)]
.Test code:
Closes #1707.