Skip to content

Save/refresh issue #790

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

Closed
1 of 3 tasks
nanaosakisan opened this issue Dec 17, 2018 · 35 comments
Closed
1 of 3 tasks

Save/refresh issue #790

nanaosakisan opened this issue Dec 17, 2018 · 35 comments

Comments

@nanaosakisan
Copy link

Nature of issue?

  • Found a bug
  • Existing feature enhancement
  • New feature request

Details about the bug:

  • Web browser and version: Firefox Version 64.0 (and the lastest version of Chrome)
  • Operating System: MacOs Sierra Version 10.12.6
  • Steps to reproduce this: don't save/refresh code's modifications when I try to run the program.
@catarak
Copy link
Member

catarak commented Dec 17, 2018

thanks for reporting @nanaosakisan! can you be more specific about how to reproduce this bug? for example, by listing out a few steps? i don't understand what the bug is.

@nanaosakisan
Copy link
Author

nanaosakisan commented Dec 18, 2018 via email

@shiffman
Copy link
Member

I have noticed some odd behavior like this after the fix for #675 was published. I think this may be related? I meant to file this a few days ago, but I forgot. You can see the trouble I was having here:

https://youtu.be/pKyU92cza0Y?t=1978

I will investigate a bit more!

@shiffman
Copy link
Member

I encountered this bug again this morning. I still cannot determine what exactly is causing it and I don't see anything in the console output. But in case this is helpful, here is the sketch:

https://editor.p5js.org/codingtrain/sketches/SJMl3u5xN

This is what I am doing:

  1. Editing lines 35 and 38 to switch add() to push().
  2. Manually saving with command-s.
  3. Run sketch.
  4. Error: Uncaught TypeError: next.add is not a function
  5. Refresh page (no warning) and code is back to add().

@shiffman
Copy link
Member

(Update I restarted browser and was able to save the change)

@catarak
Copy link
Member

catarak commented Dec 21, 2018

thanks for the updates! i'm going to dig into this.

@catarak
Copy link
Member

catarak commented Dec 21, 2018

i think what's happening here is inconsistency between what's in the editor, what's in the redux store, and what's on the server. when a sketch is saving, and then a user changes the editor, i think it's not getting into sync properly, and maybe the change i made is just exposing this.

update: i'm having a hard time consistently being able to reproduce this. i'll keep looking at this and hopefully figure it out soon 😕

@shiffman
Copy link
Member

I taught a workshop and ran into this issue a few times with attendees. I unfortunately noticed that from time to time it also does not render the code in the editor but from the last save (I think). Very mysterious! I am able to reproduce it more consistently with auto-save on, I recorded a screen capture here:

https://youtu.be/rhtIYnHICCs

Note at 46 seconds it renders background(100) while the code itself has background(220).

The video starts with autosave off and it's interesting to note that when I refresh the page you'll see the old code for a brief moment before the newly saved code replaces it.

Hope this is a bit helpful! I am happy to look into this more if anyone has suggestions for tests I can run!

@catarak
Copy link
Member

catarak commented Jan 15, 2019

thanks @shiffman—hopefully i'll figure out how to reproduce this!

@L05
Copy link

L05 commented Feb 5, 2019

I'm helping @REAS teach a class right now and we've had multiple students also encountering this issue (8+ within the past hour). They've reported saving (sometimes multiple times) over a duration only to have the code revert to an earlier version. This has happened to me as well; I'm having a hard time reproducing it consistently, but the behavior is very similar to what @shiffman has experienced in his screen captures. I'll update if I can find a reliable test case.

@bengrosser
Copy link

bengrosser commented Feb 5, 2019

I am seeing a version of this a lot over the last several days.

The symptom for me is that in the middle of writing code (or possibly also when running code), the source code in my editor pane instantly reverts to an older version, wiping out whatever changes I made in the last X minutes.

If I had that latest code running in the preview pane when this happens—and I didn't have auto-refresh turned on—then I am able to inspect the canvas (using browser dev tools) and find the most recent version of the script there so I can copy and paste it back into the editor pane. But if I had auto-refresh on, this swapping out of new code for old also changes what's in the DOM so my inspect trick doesn't work.

My suspicion is that when this code reversion happens, it is triggered when an auto-save happens, so I've turned off auto-save for the moment to see if I'm right. Will report back if I learn more. Happy to try and help further if I can—this is starting to feel regular to me (I've had it happen maybe 8 times in the last 3 or 4 days).

update--> Unfortunately, turning off auto-save isn't a useful workaround. I've had it off for the last hour and just had my code reverted.

@anuraghazra
Copy link

@shiffman @catarak I think I figured out how to recreate the bug consistently here are the steps (maybe won't work on your pc) - Auto-refresh is off

NOTE : i suspect that timing is really important in here, and i think this bug is causing differently on different Internet Speeds and throttles

  1. Create New Sketch
  2. firstly Save (ctrl + s) wait for the Project Saved and Autosave enabled message then -
  3. Change background(0) value and Save
  4. Reload (ctrl + r)
  5. Change background(100) value hit Save and then reload (ctrl+r) while the Project Saved alert is visible on screen.
  6. Again do the above step
  7. Do the above step one or two times if bug is not recreated (timing matters, I don't know how p5editor's save system works but I think timing matters in this context)

@jaytay579
Copy link

A bump on this issue and a related question. I now have my students back working locally in Brackets instead of using editor.p5js.org until we have a reliable workaround for the issue discussed in this thread, but not being able to use the online editor for in-class experimentation really slows down the pacing of an already packed-to-the-gills course!

Which brings me to my related question: Does anyone know of another online editor that we could use with P5.js in the meantime? I tried to set up a project in JSFiddle, but the way that it sandboxes code appears to be incompatible with P5's "magic functions" (that's what I call setup(), draw(), etc. with my students).

@L05
Copy link

L05 commented Feb 12, 2019

As a small follow up, I've found that disabling Autosave does not resolve this issue.

@jaytay579 I haven't tested it in a class setting, but it may be worth trying Codepen. Here's a template:
https://codepen.io/L05/pen/KJREpO?editors=0010#0

@hellonearthis
Copy link

Being a VS code fan @L05 i've been trying out blitzStack
Still I;m lucky that I've not see this problem in the p5.editor

@jbracey2004
Copy link

As far as using p5 in JSFiddle, I found this demo:
https://jsfiddle.net/SamyBencherif/5xuxrwpu/
Not sure about how it sandboxes. Looks like the magic functions work.

@catarak
Copy link
Member

catarak commented Feb 20, 2019

sorry for the slowness in getting to work on this—i've been out of town and away from my computer! this ticket is high priority and hopefully i will have a fix soon, within the next week or so.

@catarak
Copy link
Member

catarak commented Feb 21, 2019

spent some time looking at this! i think there's a couple things going on here, but i think at least merging #838 fixed one of the issues. another one is the delay in propagating data between CodeMirror (the library that this project uses for the editor) and Redux (the front-end state manager). i'm going to work on some changes for the latter, but keep me updated if you've noticed any improvements from #838 being merged.

@REAS
Copy link
Member

REAS commented Feb 21, 2019

Thank you for the update! Will do.

catarak added a commit that referenced this issue Feb 25, 2019
* for #790, when saving a sketch, pull from codemirror window

* fix lint errors
@catarak
Copy link
Member

catarak commented Feb 25, 2019

just merged some commits that should fix the scenario described by @anuraghazra (will take a few minutes to deploy), would be great to get some testing!

@shiffman
Copy link
Member

Woohoo! I'll do some serious testing of this tomorrow during class! Thank you @catarak! 🥇

@bengrosser
Copy link

bengrosser commented Feb 26, 2019 via email

@Whitevinyl
Copy link

I've recently experienced this bug similar to how Ben described it.
Working on a sketch and making multiple saves/rerunning, and then at some point when saving it reverts to a previous version.
I can't recreate it but in my case these have been projects created using the duplicate option, and they revert all the way back to the original duplication, before any changes were made.

@catarak
Copy link
Member

catarak commented Mar 12, 2019

i think the issue with duplicating reverting to an older version is a separate issue from the one i was focusing on. i'll do some investigation!

@taco-tues-on-a-fri
Copy link

I had this bug happen to me twice in the last two days. I had auto-save and auto-refresh on. While moving some code around that was introducing errors into the console the editor reverted back to a save from hours ago. All current code is gone.

@catarak
Copy link
Member

catarak commented Mar 20, 2019

i'm sorry, that's really frustrating! could this maybe have to do with having the same sketch open in different windows?

@rmacdonaldbeaver
Copy link

I've also been experiencing this problem frequently over the past week: the online editor occasionally reverts back to an old version and recent work is lost. I've been using the duplicate option, and maybe that's the source of the bug. FWIW, I've had auto-save on, but not auto-refresh. Any updates would be great. Thanks!

@catarak
Copy link
Member

catarak commented Mar 26, 2019

it could have to do with duplicating too! i think some further investigation needs to be done. but thanks for all of the updates, it's really helpful.

@catarak
Copy link
Member

catarak commented Apr 17, 2019

i'm working on some changes for this as part of #1039—it hopefully fixes some of the synching issues! i haven't been able to reproduce any issues that come up with duplicate sketches, so i'm going to keep trying to figure that out.

catarak added a commit that referenced this issue Apr 17, 2019
* add isSaving to project reducer, move actions to functions, start work to get comprehensive frontend/backend syncing working

* handle making changes while saving project, handle saving from another window

* add change to handle saving new sketch, and adding new changes while saving
@rmacdonaldbeaver
Copy link

I haven't had any issues recently, but I've also been avoiding any duplication... Huge thanks for looking into this. Hoping to prevent frustrations for students who are new to coding.

@catarak
Copy link
Member

catarak commented Apr 17, 2019

@rmacdonaldbeaver for sure! let me know if you notice anything weird. it's much easier for me to fix stuff if i have concrete steps to reproduce 😸

@REAS
Copy link
Member

REAS commented Apr 17, 2019

Thank you @catarak! I haven't been teaching with the Editor this quarter, so I haven't had the chance to notice the issue.

@cheriesdavidson
Copy link

I've just experienced this issue or something very similar. I've been working on a project on and off for a few weeks, and today it's reverted back about a week (the open project window has the last change dated from 5 days ago and it appears nothing has saved after that point).
I have autosave on, auto-refresh off and often hit ctrl-S out of habit. I work with multiple sketch files and all have reverted inc. name changes. Sometimes I sleep & wake my laptop with the page still open and continue work.
I noticed when closing the tab last night I had something similar to #675 occur with an unsaved work warning dialogue. I remember cancelling the close operation, hitting ctrl-S (I can't recall if the dot disappeared or if there was a save project confirmation - but I think maybe the dot disappeared and the confirmation didn't occur), and thinking it must be saved. I went to close the tab again and had the same warning, but felt safe that it was actually saved given I had autosave on and had manually hit save.
Today, I was able to change a few characters in a file and the save appears to work as expected
I assume these files updates are now lost to time :( ?

@catarak
Copy link
Member

catarak commented Dec 5, 2019

i'm sorry this happened @cheriesdavidson! did you possibly have the sketch open in multiple tabs?

@catarak
Copy link
Member

catarak commented Feb 10, 2021

I'm going to close this just so folks will open a new issue if errors are coming up again! I think this will be fixed by some stuff discussed in #1337.

@catarak catarak closed this as completed Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests