Skip to content

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

Merged
sebavan merged 1 commit into
BabylonJS:masterfrom
Ameobea:string-size-limit-workaround
Oct 19, 2022
Merged

sebavan merged 1 commit into
BabylonJS:masterfrom
Ameobea:string-size-limit-workaround

Conversation

@Ameobea

@Ameobea Ameobea commented Oct 19, 2022

Copy link
Copy Markdown
Contributor

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

sebavan commented Oct 19, 2022

Copy link
Copy Markdown
Member

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