Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

webGL black screen when loading

Discussion in 'WebGL' started by jimjim, May 27, 2015.

  1. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    When i run my webgl game it loads the game but then shows a blank screen when loaded. when i load it again i get this message

    'An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was:
    uncaught exception: out of memory'


    I have set my memory size to 512 and 750 and always get this mesage i have tried different optimization levels too and still get the same results. I have also tried less but then it tells me it is not enough. Any help you can give me will be greatly appreciated
     
  2. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    i have stripped my game to nothing and still get a black screen on load any help, would be most useful
     
  3. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
    This isn't a clear cut issue. The browsers have to allocate the memory you set as one block. If you have not enough memory or the memory is very fragmented you will get the out of memory error even though the 500MB you set might be enough for your game to run.

    Starting on an empty browser and using a 64bit browser will help with this issue.
     
  4. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    i think it is a script issue. removed some scripts and it worked. Trying to work out what was wrong with script now. any spceicfc script setup that i have to follow to get project working
     
  5. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    Fixed it was a code issue. I added a condition within my code for webGL:

    Code (csharp):
    1.  Application.platform == RuntimePlatform.WebGLPlayer[/[code=CSharp]
    that got rid of the code issue
     
    Last edited: Jun 1, 2015
  6. Linck

    Linck

    Joined:
    Dec 21, 2013
    Posts:
    9
    @jimjim, so your script was causing a black screen only on web gl? Could you share what code exactly?
     
    devluz likes this.
  7. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    the black screen was caused by us using a fadeout screen at the start of the game. the code then got stuck on a piece of code that did not exist in webgl build as it was looking for extenal function in the webplayer build that did not exist
     
  8. Linck

    Linck

    Joined:
    Dec 21, 2013
    Posts:
    9
    hmmm, got it
     
  9. krmaicher

    krmaicher

    Joined:
    Oct 9, 2014
    Posts:
    4
    Where exactly did you implement this line?
     
  10. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    the if condition was used to stop the code being able to access scripts that did not exist in the webgl build, but did exist in the webplayer build. The problem i had was it was trying to access javascript code that was not part of the webgl build. The line was just implemented to only use this code for certain builds