Uh oh!
There was an error while loading. Please reload this page.
[browser][mt] Update memory views after growth, refactor string processing, fix SharedArrayBuffer detection - #86664
Conversation
…ffer from different JavaScript realm When performing tasks such as allocating or marshalling large amounts of memory in multithreaded .NET land, inconsistent and frequent crashing behavior is exhibited. Related issues: emscripten-core/emscripten#15217https://github.com/dotnet/aspnetcore/issues/48390
IsaMorphic
commented
May 23, 2023
@dotnet-policy-service agree |
Uh oh!
There was an error while loading. Please reload this page.
kg
commented
May 23, 2023
Thanks for your contribution! If I understand correctly, this instanceof bug affects scenarios involving iframes because the iframe is a different realm and has its own builtins like Array and SharedArrayBuffer, right? So any case where we are using instanceof is potentially broken in that case, which is what motivates APIs like Array.isArray. |
IsaMorphic
commented
May 23, 2023
Hi @kg! That's exactly the scenario I came across that motivated this fix. I'll get to work right away on a solution that avoids the call to I'm glad to help! |
… time avoiding call to Object.toString
Uh oh!
There was an error while loading. Please reload this page.
pavelsavara
commented
May 24, 2023
ghost
commented
May 24, 2023
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsWhen performing tasks such as allocating or marshalling large amounts of memory in multithreaded .NET land, inconsistent and frequent crashing behavior is exhibited. I adapted a fix to this issue from this PR in the emscripten repository: Related issues:
|
@pavelsavara Please see the latest commit on my fork's I have not tried to see if my patch helps, as I have not built the runtime with the Hope this is helpful. Update: I don't know where in the code this corresponds to. If someone can point me to it so I can update the file with the same |
pavelsavara
commented
May 25, 2023
"memory pooling or reclamation mechanism that they use internally that causes buffers to cross the iframe boundary" could you please point me to more details about it ? |
pavelsavara
commented
May 25, 2023
Also, if there is buffer reuse across iframes, it should also manifest without threads, right ? @radekdoulik would we capture/notice the error if one of the AppStart measures failed to start the runtime in the iframe ? |
pavelsavara
commented
May 25, 2023
I get it now, in our benchmark it's not a |
pavelsavara
commented
May 25, 2023
main...IsaMorphic:runtime-wasmfix:broken-sample I will have look soon, probably next week. Thanks a lot! I would still love to read about how this is not a browser bug. :-D |
pavelsavara
commented
May 25, 2023
pavelsavara
commented
May 26, 2023
I processed further feedback from @kg about not calling While doing that I noticed that we have too many loops where we convert strings with different encodings, so I moved all of it into @ilonatommy I touched some of the hybrid locale stuff, please have look. There is bit of risk that this change will introduce perf regression, but it was that already yesterday. |
pavelsavara
commented
May 26, 2023
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
pavelsavara
commented
May 26, 2023
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ilonatommy
left a comment
There was a problem hiding this comment.
Globalization pointer math checked.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pavelsavara
commented
May 26, 2023
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
pavelsavara
commented
May 28, 2023
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
pavelsavara
commented
May 30, 2023
I guess this is that we eliminated bunch of checks in the non-MT string conversion. |



"memory pooling or reclamation mechanism that they use internally that causes SharedArrayBuffer to cross the iframe boundary"
SharedArrayBufferviabuffer[Symbol.toStringTag] === "SharedArrayBuffer"copyBufferIfNecessaryhelperreceiveWorkerHeapViewsModule.HEAPxx with newlocalHeapViewXXX()receiveWorkerHeapViewsand produces updated short lived "local" view-s TEXTDECODER=0emcc linker flag for MT buildModule.UTF8ArrayToStringandModule.UTF8ToStringwith our ownutf8ToStringanddecodeUTF8TextDecoderfor longer strings instead of emscripten byte-by-byte loopencodeUTF8andutf8ToStringRelaxedofstrings.tsHEAPU8overHEAP8for code consistencystring.tsrefactoringFixes#86696
Fixes#86642
Related issues:
emscripten-core/emscripten#15217