Skip to content

Fix crashes caused by browser string size limit for large captures #244

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

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

Ameobea
Copy link
Contributor

@Ameobea Ameobea commented Oct 19, 2022

When making some very large captures, such as those with thousands of commands and the "Full Capture" option enabled, serialization of the resulting capture to JSON can fail due to browser max string size limitations. Even though there is some chunking done on the generated JSON string to avoid other message port limits, that doesn't help with the actual generation of the JSON string.

This checks for the error created when the resulting JSON string would be too long and attempts to handle it with a fallback implementation. It does this by replacing the inner commands list from the capture with a placeholder string before serializing and then doing some manual string concatenation to generate chunks that produce a valid JSON when received by the client.

Testing locally, this fixes the issue and allows me to perform captures I wasn't able to before. I still get some captures that fail due to what I think are global memory limits on the extension or JS runtime as a whole or something, but idk if there's a way to fix those without doing big changes to the app.

 * When making some very large captures, such as those with thousands of commands and the "Full Capture" option enabled, serialization of the resulting capture to JSON can fail due to browser max string size limitations.  Even though there is some chunking done on the generated JSON string to avoid other message port limits, that doesn't help with the actual generation of the JSON string.
 * This checks for the error created when the resulting JSON string would be too long and attempts to handle it with a fallback implementation.  It does this by replacing the inner `commands` list from the capture with a placeholder string before serializing and then doing some manual string concatenation to generate chunks that produce a valid JSON when received by the client.
@Ameobea Ameobea changed the title string size limit for large captures Fix crashes caused by browser size limit for large captures Oct 19, 2022
@Ameobea Ameobea changed the title Fix crashes caused by browser size limit for large captures Fix crashes caused by browser string size limit for large captures Oct 19, 2022
@sebavan
Copy link
Member

sebavan commented Oct 19, 2022

Yes, it is amazingly annoying and so glad you are proposing a PR for it !!!

@sebavan sebavan added the bug label Oct 19, 2022
@sebavan sebavan merged commit d91c4e8 into BabylonJS:master Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants