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. Dismiss Notice

Question location.reload causes RuntimeError: memory access out of bounds on some Android devices

Discussion in 'WebGL' started by Good_Punk, Jun 15, 2021.

  1. Good_Punk

    Good_Punk

    Joined:
    Aug 6, 2014
    Posts:
    81
    Hello,

    I'm trying to reload my client from a JS call with document.location.reload(true);
    The page is reloaded but on some (seemingly not all) Android devices I get a Runtime error afterwards in Chrome. Any ideas how to fix that?

    Cheers
     
  2. Good_Punk

    Good_Punk

    Joined:
    Aug 6, 2014
    Posts:
    81
    Ok great... when I do an development build the error disappears. But the reload of the page seems to break something... my wrapped inputfields don't open the mobile keyboard anymore. *sigh*
     
  3. Good_Punk

    Good_Punk

    Joined:
    Aug 6, 2014
    Posts:
    81
    Interesting... when the text input is broken not even a manual reload of the page helps. But if I switch to another tab and back it suddenly works again.
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
    This sounds like the browser is running out of memory with the old instance's memory of your app not being collected yet but the browser trying to resevere another big chunk for the new one.

    Do the devices you see the issue on have less memory available compared to the ones you aren't seeing this on?

    The input field issue seems indeed to be odd. Could you please file a bug for this? Thanks!
     
  5. Good_Punk

    Good_Punk

    Joined:
    Aug 6, 2014
    Posts:
    81
    > Do the devices you see the issue on have less memory available compared to the ones you aren't seeing this on?
    I only have three test devices atm so it's hard to tell. I thought about running Application.Quit before reloading the website but as I'm calling the location.reload(); from jslib I don't know how/if I could do that.
     
  6. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
  7. Good_Punk

    Good_Punk

    Joined:
    Aug 6, 2014
    Posts:
    81
    Not 100% sure. What I've tried was from Unity side to first call the JS function that reloads the page and do Application.Quit() right afterwards but the result was that the page didn't reload anymore. I thought that the Quit might destroy the jslib before it executes the reload? I don't know much about JS and how these things work... so maybe the other way around, as you proposed - calling the Unity from JS - would work.
     
  8. cristydavidd

    cristydavidd

    Joined:
    Sep 20, 2022
    Posts:
    1
    The reload() function takes an optional parameter that can be set to true to force a reload from the server rather than the cache. Since window.location.reload(true) has been deprecated, changing location.reload(true) to location.reload() to resolve this issue. Also, you can use:

    window.location.href = window.location.href;

    There are multiple ways to Refresh/Reload a page with jQuery/JavaScript, some are:

    location.replace(location.pathname)
    window.location = window.location
    window.self.window.self.window.window.location = window.location