BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
13.01k stars 432 forks source link

[🐞] SharedArrayBuffer crash #402

Open ashleyjlive opened 1 year ago

ashleyjlive commented 1 year ago

Describe the bug

image

Hey guys, it looks like there's an issue with Partytown when using atomics. We encounter the error (see photo attached) fairly regularly in our error logs - particularly on Android Chrome devices. It looks like it's related to the following code: https://github.com/BuilderIO/partytown/blob/ab532e6ed6586bee30072a80d7379ac7d3eae240/src/lib/atomics/sync-create-messenger-atomics.ts#L12-L13 Is there a reason why 1gb of memory is being allocated straight up? I would consider making this initialisation much smaller and utilising the maxByteLength property in the options to allow up to something more reasonable (say 100mb). For example: new SharedArrayBuffer(1024, { maxByteLength: 1024*1024} );

Reproduction

https://www.youi.com.au/

Steps to reproduce

On Android Chrome browsers (check browserstack android V9), navigate to https://www.youi.com.au and the console error will be present.

Browser Info

Android Chrome

Additional Information

No response

ashleyjlive commented 1 year ago

I'd also suggest a fallback in the instance that the SharedArrayBuffer couldn't be created (due to low memory or some other issue).

JamesCrann commented 7 months ago

Any updates on this please?