Skip to content

Comments

Fix: Ensure SDK global availability for Unity WebGL Decompression Fallback#14

Open
TanguyPinpin wants to merge 1 commit intoByteBrewIO:mainfrom
TanguyPinpin:patch-1
Open

Fix: Ensure SDK global availability for Unity WebGL Decompression Fallback#14
TanguyPinpin wants to merge 1 commit intoByteBrewIO:mainfrom
TanguyPinpin:patch-1

Conversation

@TanguyPinpin
Copy link

Changed scope, as it was causing a crash on recent versions of Unity when using Decompression Fallback.

When using Decompression Fallback, the loading environment executes .jspre files within a restricted scope, resulting in the SDK becoming inaccessible to .jslib functions.

By passing window explicitly into the anonymous factory function we guarantee that the SDK is attached to the browser's global object, making it reachable by the jslib bridge regardless of how the fallback loader executes the script.

// From:
}(this,()=>((()=>{ ...

// To:
}(window,()=>((()=>{ ...

Changed scope, as it was causing a crash on recent versions of Unity when using Decompression Fallback.

When using Decompression Fallback, the loading environment executes .jspre files within a restricted scope, resulting in the SDK becoming inaccessible to .jslib functions.

By passing window explicitly into the anonymous factory function we guarantee that the SDK is attached to the browser's global object, making it reachable by the jslib bridge regardless of how the fallback loader executes the script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant