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

client doesn't update portions when entering large code #82

Open
Ponali opened this issue Mar 3, 2024 · 3 comments
Open

client doesn't update portions when entering large code #82

Ponali opened this issue Mar 3, 2024 · 3 comments
Labels
song code issue Something is wrong with the code in the editor. wontfix This will not be worked on

Comments

@Ponali
Copy link

Ponali commented Mar 3, 2024

when large amounts of valid javascript code is inserted, the client does not update the sample rate nor the link to the page (normal behaviour would normally turn the URL to have the code after the hashtag.)
when setting the sample rate, it does not do anything to the audio, when reloading, the sample rate option defaulted back to before i set it.
when inserting large amounts of code, the URL does not update, meaning that when reloading, the code dissapears, and defaults back to before i set the large portion of code.
this is what i can gather from DevTools that is related to this subject:
image
image

@SArpnt
Copy link
Contributor

SArpnt commented Mar 12, 2024

most code with any errors don't update the url. your code is almost certainly infinitely recursive, which still means it's broken. firefox seems to just crash the tab when this happens, it doesn't even report an error.

the player might be able to handle the error a bit better, but it can't make the code work and it can't make it work in all browsers. you should probably just fix your bytebeat code for now.

@Chasyxx
Copy link

Chasyxx commented Apr 2, 2024

window.location.hash = `#v3b64${ btoa(String.fromCharCode.apply(undefined, deflateRaw(JSON.stringify(songData)))).replaceAll('=', '') }`;
I think the error appears in the String.fromCharCode.apply like devtools says. If a code is large enough even after being compressed with pako, turning each element of it into it's own parameter probably would use up the call stack eventually. This is not an issue with an individual bytebeat code and is to do with the player itself.

I'm wondering if instead of running String.fromCharCode on the entire thing in a single pass like this, you map each element of the array to a character individually and then join it into a single string:

window.location.hash = `#v3b64${ btoa(deflateRaw(JSON.stringify(songData)).map(k=>String.fromCharCode(k)).join('')).replaceAll('=', '') }`;

Or turn the bytes into characters one by one:

let bytes = deflateRaw(JSON.stringify(songData)).reverse();
let str = "";
while(bytes.length>0) {
    str+=String.fromCharCode(bytes.pop());
}
window.location.hash = `#v3b64${ btoa(str).replaceAll('=', '') }`;

I can imagine these are slower, but they might fix the issue. iirc firefox does say "Too many parameters passed to String.charcode.apply" or something like that.

@SArpnt
Copy link
Contributor

SArpnt commented Apr 4, 2024

the map would be better. firefox limits the amount of function arguments to 50000, which is sufficient for well written code, but function arguments aren't meant to act as arrays. although i think that 50k for a single bytebeat isn't a good way to go about making bytebeats, it's entirely reasonable someone would hit that number with some inefficient auto generation tool or audio samples.

@SthephanShinkufag SthephanShinkufag added wontfix This will not be worked on song code issue Something is wrong with the code in the editor. labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
song code issue Something is wrong with the code in the editor. wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants