Skip to content
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

🪲 Switching to another tab with an ask prompt open, causes the program to mix up #5211

Closed
jpelay opened this issue Mar 5, 2024 · 2 comments · Fixed by #5225
Closed

🪲 Switching to another tab with an ask prompt open, causes the program to mix up #5211

jpelay opened this issue Mar 5, 2024 · 2 comments · Fixed by #5225
Assignees
Labels
bug Something isn't working

Comments

@jpelay
Copy link
Member

jpelay commented Mar 5, 2024

Describe the bug
To reproduce this bug do the following:

  1. Student beging to runs program
  2. Then student switches to another adventure, while previous program still has an ask propmpt open
  3. When the student runs the new program, somehow skulpt still is processing the old ask prompt (handled internally as a promise), and then everything gets mixed up
@jpelay jpelay added the bug Something isn't working label Mar 5, 2024
@Felienne Felienne moved this to ToBeDiscussed in Hedy organization board Mar 5, 2024
@AnneliesVlaar
Copy link
Collaborator

I noticed the same problem when I used if key is pressed.

@jpelay
Copy link
Member Author

jpelay commented Mar 7, 2024

I noticed the same problem when I used if key is pressed.

Yes, that happens because the ask command and the ifpressed command use the same internal mechanism!

@mergify mergify bot closed this as completed in #5225 Mar 12, 2024
mergify bot pushed a commit that referenced this issue Mar 12, 2024
In Skulpt there really isn't a way to stop the execution of a program. If the program uses things like prompts for the `input` function, or sleep, then those promises are still somewhere in the JavaScript handler. Therefore, when you execute a new program while another one is still waiting for a promise to be fulfilled (i.e: waiting for user input through an ask prompt), when the new program finishes execution, the old one will continue its path.

To fix this I added a new field to `sessionStorage` which will have an id for the program being executed, and I edited Skulpt to pass the id of the program. Therefore, when an old program is being executed, its id will be different than the current one and therefore will finish its execution.


Fixes #5211

**How to test**

* Go to level 14 and execute the TicTacToe adventure, fill the first ask.
* With an ask prompt still open, switch to the Quizmaster tab and execute the program.
* Only the Quizmaster program should be executed.
boryanagoncharenko pushed a commit that referenced this issue Mar 13, 2024
In Skulpt there really isn't a way to stop the execution of a program. If the program uses things like prompts for the `input` function, or sleep, then those promises are still somewhere in the JavaScript handler. Therefore, when you execute a new program while another one is still waiting for a promise to be fulfilled (i.e: waiting for user input through an ask prompt), when the new program finishes execution, the old one will continue its path.

To fix this I added a new field to `sessionStorage` which will have an id for the program being executed, and I edited Skulpt to pass the id of the program. Therefore, when an old program is being executed, its id will be different than the current one and therefore will finish its execution.


Fixes #5211

**How to test**

* Go to level 14 and execute the TicTacToe adventure, fill the first ask.
* With an ask prompt still open, switch to the Quizmaster tab and execute the program.
* Only the Quizmaster program should be executed.
@Felienne Felienne moved this from ToBeDiscussed to Done in Hedy organization board Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants