Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Runtime Crash: Context_lost_webgl (2d Text Renderer)

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

  1. Jalol

    Jalol

    Joined:
    Sep 23, 2013
    Posts:
    26
    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: http://flyingbeavers.ca/tinytests/TinyCrash/ReleaseBuild/

    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 {
    5.  
    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
    9.  
    10.      
    11.         OnUpdate():void {
    12.                  
    13.             this.world.forEach([ut.Entity, ut.Text.Text2DStyle, ut.Text.Text2DRenderer],
    14.                 (entity, style, text) =>
    15.                 {
    16.                     let entName = this.world.getEntityName(entity);
    17.                     let fishcount = SceneConfigBehavior.TotalFishCount;
    18.  
    19.                     if (fishcount == null)
    20.                     {
    21.                         console.log(ut.Time.time() + " - Fishcount not valid");
    22.                         return;
    23.                     }
    24.  
    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.                 });
    31.  
    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

    Jalol

    Joined:
    Sep 23, 2013
    Posts:
    26
    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

    Tomiha_be

    Joined:
    Jan 14, 2016
    Posts:
    8
    *bump*

    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

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    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

    raymondyunity

    Unity Technologies

    Joined:
    Apr 30, 2018
    Posts:
    122
    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

    austinkelleher

    Joined:
    Feb 24, 2014
    Posts:
    1
    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
     
  7. jzq740176597

    jzq740176597

    Joined:
    Jul 31, 2015
    Posts:
    17
    I have the same issue ? webGL (chrome switching different tabs <each ref same 3D package in webgl , ie: wasm>)
    Any one helps? the unity support?
    7-7-2020 9-51-16 AM.jpg
     
  8. AbdulAlgharbi

    AbdulAlgharbi

    Unity Technologies

    Joined:
    Jul 27, 2018
    Posts:
    319