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

State persistance issue (FF) #50

Open
Geist-zz opened this issue Jun 27, 2022 · 3 comments
Open

State persistance issue (FF) #50

Geist-zz opened this issue Jun 27, 2022 · 3 comments
Labels

Comments

@Geist-zz
Copy link

Geist-zz commented Jun 27, 2022

Problem:
If program hangs interpreter in Firefox, after stopping the js script and refreshing the tab, the interpreter will autorun the bad program (even if you paste the url of the interpreter in another tab). And this continues after restarting the browser.

What should happen:
The interpreter shouldn't autorun the program (on refresh / restart of the browser / pasting interpreter url in another tab). Or it should load the demo program instead of auto-executing the custom code.

Bypass:
Switching HTTP protocol (from ex. http to https) allows you to run new instance of interpreter. Side note: under https, the tape storage doesn't work (tape list doesn't show).

Code that hangs the script (in the last 3 lines I didn't add "10" to the line numbers in THEN and GOTO):

1000 A=100:GOTO20
1010 LET W=500:DIM F(W):LET P=1:LET A=3
1020 LET F(P)=A:LET P=P+1:IF P>W THEN GOTO 950
1030 LET A=A+2:LET X=1
1040 LET S=A/F(X):IF S=INT(S) THEN 30
1050 LET X=X+1:IF X<P AND F(X)*F(X)<=A THEN 40
1060 GOTO 20
@robhagemans
Copy link
Owner

Yes, that definitely seems to make the page unusable.

If you have this issue, you can also work around by deleting the local storage for robhagemans.github.io which ill reset the interpreter to the default program. In Firefox e.g. through the privacy tab under settings, where you can manage site data.

In terms of how to resolve this, that's not immediately clear. State does need to persist on reloading the page - otherwise people would lose their program and settings which are all in local storage for the page. And having the canvas run automatically on a page is also a desirable feature in general. It may be possible to make things dependent on whether people opened new tabs etc. as you describe, but I'd have no idea how to do that. It may be possible to just have a great big red reset button, though the program seems to hang the script altogether so it might not actually respond to that.

Underlying bug is that the script hangs in the first place, which is likely caused by the GOTO 20 which makes the program run in a loop. Somewhat curious that it leaves the script unresponsive though.

@robhagemans
Copy link
Owner

By the way re the tape under https, that works fine for me in Firefox. Note that the tape and floppy are actually empty by default, and you'd need a program to write to it first. E.g. https://robhagemans.github.io/basicode/basicode/Basicode-3/06_Adresbestand.bc3 can read and write from tape (not sure if there's an English version around in the repository, sorry)

@Geist-zz
Copy link
Author

Geist-zz commented Jun 30, 2022

Emergency stop button probably could work (or maybe just splitting of the run/stop button), because when I was spamming clicking on the run/stop button, I saw that it changed state to stop for a moment (but it's hard to stop at the right moment when you click as fast as possible).

Tape: Most likely the tape state was remembered from the program loaded prior to a pasting of custom code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants