ffd8 / P5LIVE

p5.js collaborative live-coding vj environment!
https://p5live.org
GNU General Public License v3.0
226 stars 35 forks source link

Feature request: Support multiple files #53

Closed guidobouman closed 3 years ago

guidobouman commented 3 years ago

When doing a hackathon with multiple artists, the main sketch gets a rather big quite quickly:

The option to split the code into different files like with p5.js online editor would be really nice!

How do you think that could work?

guidobouman commented 3 years ago

Added bonus: the editor gets REALLY slow when it has over 300 lines of code. The thread freezes for about 2 seconds after each keystroke. A recorded profile shows that the problem is in the ACE editor keydown handle, not sure why.

Edit: I'll submit this as a separate bug, as this performance bug should be fixable regardless of the multi file feature.

ffd8 commented 3 years ago

Curious how this would work simply, while not expanding the codebase/complications of sync in cocoding in crazy way. At the moment, there's only the one single ace editor contents being synced (using peeredit which is linked directly to ace editor instance). All sorts of things like cursor position, deltas etc are linked to this... potenitally it could be written as a class - where additional instances are possible – keeping track of which ace-editor one is working in? Or is there a way to semi fake it, with the appearance of multiple windows/tabs/whatever – but really it's a singular text block? Because when you 'clone the sketch' for saving locally – which window would it save??

There's lots of reasons to use the p5 online editor (particularly assets and split scripts) – in P5LIVE, ease/vj/minimal_interface etc are given priority. So I'm def up for exploring the idea, but would have to avoid being invasive for user (since this needs to work as well for total beginner as pro user).

Re: lag out after lots of lines of code.. strange – are you speaking just of the cocoding context? I have a few sketches with 1000+ lines of code and never ran into issues. Be sure the background color to your editor code is fully opaque. Nevertheless, would be interesting to isolate the issue– best to open a another issue and try sharing some demo code where it occurs.

ffd8 commented 3 years ago

For now I'm going to close this, since I don't have plans to implement a function for multiple-files.. in that case, it's best to use the p5 web-editor, glitch.com, or working locally with a syntax highlighter...

Regarding the lag.. please feel free to open a new issue – curious if it's something with ACE that's been resolved in the meantime (I try to keep up to date with their latest version) or more likely, something about the syncing of ACE over websockets (using peeredit as linked above) and maybe that slowly bogging down with a big history? Been looking for a way to cleanly purge/reset the synced history if getting too long (with garbage that no longer needs to be synced) – but haven't found a way just yet...

ffd8 commented 3 years ago

@guidobouman FYI, I think I caught the bug that was causing massive lag with many lines of code. Randomly ran into it as well while working on last update.. then noticed a craaazy issue with DOM pollution and my manual span tags for adding background to the lines of code – somehow when making a selection with mouse pressed down, it was creating TONS of nested spans, rather than removing/updating existing ones....?? Anyways, added some logic to not add a span to a line if it already exists and I haven't seen the issue since! See #61 for details, and curious if it fixes the issues you had.

guidobouman commented 3 years ago

Thanks for getting back to this issue. Not using it right now. Will try to do a collaborative hack session again some time soon. Will let you know how it fares!