Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Runtime Crash: Context_lost_webgl (2d Text Renderer)

Discussion in 'Project Tiny' started by Jalol, Apr 10, 2019.

  1. Jalol


    Sep 23, 2013
    Hi there !

    I am encountering a fatal crash at Runtime related to a 2D text renderer and it's text updates.
    Basically if I update the text during Update, the renderer crashes without displaying errors and does not recover.

    I was making a simple project spawning a lot of fishes and displaying framerate/fishcount.
    You can try the project here:

    Steps to reproduce
    - Run the page on the linkk (or build the tiny project enclosed in debug, dev or release)
    - Run for 2-10 sec
    - Refresh/restart if it does not happens in the first seconds

    Current behavior:
    The chrome tab become white and displays a sad smiley on the top-left corner. The console displays the following warning (first line) and a simple log entry (second line).
    (index):1 WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
    runtime.js:156347 Free all GL resources.
    Note: only the rendering part of the project is broken: console.log from other systems keep appearing in the console AFTER the crash.

    Expected behavior:
    Either don't crash or tell me where/what I screwed up ;)

    Where I think it comes from:
    Code (JavaScript):
    1. namespace game {
    2.     @ut.requiredComponents(ut.Text.Text2DRenderer)
    3.     @ut.requiredComponents(ut.Text.Text2DStyle)
    4.     export class StatDisplaySystem extends ut.ComponentSystem {
    6.         enable: boolean = true;
    7.         timeLastUpdate: number = 0; // Last time the text was updated
    8.         delayBetweenUpdate: number = 0; // Delay between update, 0 to trigger the issue quickly
    11.         OnUpdate():void {
    13.   [ut.Entity, ut.Text.Text2DStyle, ut.Text.Text2DRenderer],
    14.                 (entity, style, text) =>
    15.                 {
    16.                     let entName =;
    17.                     let fishcount = SceneConfigBehavior.TotalFishCount;
    19.                     if (fishcount == null)
    20.                     {
    21.                         console.log(ut.Time.time() + " - Fishcount not valid");
    22.                         return;
    23.                     }
    25.                     if (entName == "FishCountLabel" && this.timeLastUpdate < ut.Time.time())
    26.                     {                  
    27.                         text.text = fishcount+ " fish";
    28.                         this.timeLastUpdate = ut.Time.time() + this.delayBetweenUpdate;
    29.                     }
    30.                 });
    32.         }
    33.     }
    34. }
    I am posting this hoping that I missed something obvious but if I didn't others will know about the issue ;)

    PS: I am working with Unity 2018.5.5f1 and Tiny 14.3. Deleting Library, reinstalling the package or Updating runtime did not solve the issue.
    PPS: I know C# is coming soon, I was just making a proof of concept and that crash is the only issue remaining before I can show off ;)

    Attached Files:

    Pakor and Deleted User like this.
  2. Jalol


    Sep 23, 2013
    I worked around that issue by switching to Bitmap font but it looks very pixelated :(
    I may have to hide the performances stats for now ^^

    EDIT: nope, still crashing randomly with bitmap fonts.
    Last edited: Apr 11, 2019
    Pakor likes this.
  3. Tomiha_be


    Jan 14, 2016

    We are experiencing the exact same problem. Pretty annoying...
    Is there something we can do from our side to counter this? (except switching to Bitmap fonts)
    Will this be resolved in the next Project Tiny version?
    Pakor likes this.
  4. Pakor


    Feb 2, 2017
    I am experiencing this issue as well. If I play my game more than once, it crashes on the second playthrough with the exact same error Jalol had. I hope this can get fixed soon, or someone can tell us what we are doing wrong
  5. raymondyunity


    Unity Technologies

    Apr 30, 2018
    There seems to be a runtime issue with text. We'll be adding this to our tests so it won't happen again.
    Jalol, Pakor and Tomiha_be like this.
  6. austinkelleher


    Feb 24, 2014
    I've also seen issues with receiving CONTEXT_LOST_WEBGL. Specifically when switching tabs for a few minutes. Is this something that is being worked on?

    Version: Unity 2019.1.11f1