Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Chromebook WebGL context creation failed on Chrome versions >112

Discussion in 'Web' started by dseabolt_il, May 4, 2023.

  1. dseabolt_il


    Jan 18, 2018
    We have customers who are seeing Unity not start when Chrome updated to 112. I've done some preliminary investigation and found that it seems to be mostly effect Chromebooks running old Celeron processors and it seems to be failing when trying to create a context that has the attribute `"premultipliedAlpha":false`. It effects all WebGL projects, not just Unity builds.

    Since this doesn't seem to be Unity's fault per se, I'd like some help to figure out how to hijack the UnityModule and prevent it from setting that attribute. It's causing a lot of problems. I've done a grep in the Unity code and in my Project and can't find that phrase, so it must be in a binary file somewhere. Could I get some assistance?
  2. dseabolt_il


    Jan 18, 2018
    For anyone else who may be running into this issue, if you go on to your build machines and go to your Unity install location/WebGL Support/BuildTools/Emscripten/src there is a file called
    . In there if you scroll down to line 2157 for my version, but you're looking for a function that is setting up an array of attributes for createContext. In there I added these lines:
    Code (JavaScript):
    2. console.log(“Overiding Unity default premultipliedAlpha”);
    4. contextAttributes[“premultipliedAlpha”] = true;
    Note, if your application relies on blending with the canvas, it won't work anymore. Hope this helps anyone else stuck here. It's a very hacky fix, and I'm assuming Chrome will fix it eventually. Here's the Chromium ticket if they ever do:
    jeffreylanters likes this.
  3. jeffreylanters


    May 8, 2013
    We've encountered the same issue where our games fail to start on Chromebooks that run ChromeOS 112. Your proposed temporary solution does fix the problem, but there's a simpler way to enable premultipliedAlpha without the need to delve into the compiler.

    You can easily overwrite the WebGL's Context Attributes in the createUnityInstance method. Simply provide the webglContextAttributes object to the UnityParameters and overwrite the required attributes. You can find more attributes that can be overwritten by visiting

    Here's an example of how to implement it in the createUnityInstance method:

    Code (JavaScript):
    1. createUnityInstance(someCanvasReference, {
    2.   dataUrl: "unitybuild/",
    3.   frameworkUrl: "unitybuild/module.framework.js",
    4.   codeUrl: "unitybuild/module.wasm",
    5.   // Add the `webglContextAttributes` object to the UnityParameters
    6.   webglContextAttributes: {
    7.     // Overwrite the required attributes
    8.     premultipliedAlpha: true,
    9.   },
    10. });
    dseabolt_il likes this.
  4. alexstonefilament


    Jul 14, 2015
    jeffreylanter's solution is for Unity 2020 and above. For older versions of Unity, use this syntax:

    Code (JavaScript):
    1. gameInstance = UnityLoader.instantiate("gameContainer", "Build/release.json", {
    2.   Module: {
    3.     webglContextAttributes: {
    4.       // Overwrite the required attributes
    5.       premultipliedAlpha: true,
    6.       preserveDrawingBuffer: false,
    7.     },
    8.   },
    9. });
  5. adamgolden


    Jun 17, 2019
    I'm wondering if there's a performance impact to using the premultipliedAlpha workarounds noted above, ..I mean if we want WebGL builds working on the broken Chromebook Chrome versions, is it safe/performant just to enable premultipliedAlpha always, or should there be Chrome OS detection + Chrome browser detection (if Chromebooks run other browsers - I don't know anything about them)?

    A quick idea based on pages here and here I thought the below approach might work, but maybe it could be improved further with a version test so older versions could still run without the [potential] overhead of the workaround - does anyone have a tested/working approach to solve this conditionally? I don't have a Chromebook or know anybody with one, so I can't test this myself.. but maybe as a way to specifically target only that browser:
    Code (CSharp):
    1. premultipliedAlpha: (/\bCrOS\b/.test(navigator.userAgent) && Boolean(