Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

quit and memory cleanup

Discussion in 'Web' started by Marco-Trivellato, Oct 19, 2018.

  1. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Thanks @Tocic_Elmo , it sounds like Decompression Fallback pins down the loaded Unity content from garbage collecting. Could you report that as an issue? That would help a lot!

    @bennythejet Interesting to see that Chrome is able to clean up, but Firefox is not. That suggests a Firefox GC issue. Still, go ahead and report the issue to Unity, we'll route it over to Mozilla if it is the case.
     
    bennythejet likes this.
  2. Toxic_Elmo

    Toxic_Elmo

    Joined:
    Aug 30, 2020
    Posts:
    5
    Last edited: Feb 22, 2021
    bennythejet likes this.
  3. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Thanks, QA should reproduce it and forward it to the web team to handle.
     
  4. cloghead

    cloghead

    Joined:
    Jan 18, 2022
    Posts:
    1
    I have tried the sample project - and also freshly generated projects - but whatever settings I use I get a memory leak, both with 2020 and 2021 builds, both with Firefox and with Chrome, with devtools closed etc. I have only tried uncompressed files though, but according to the comments that is what should work.
    You can check behavior at https://cloghead.github.io/webglmemtest/ of repo https://github.com/cloghead/webglmemtest. This is generated with the latest 2021 Unity version (2021.2.11f1).
     
    LoneGoat likes this.
  5. bkaraceylan

    bkaraceylan

    Joined:
    May 3, 2021
    Posts:
    9
    I am running issues with both methods of quitting the application. It loops a Quitting... log with memory errors.

    Unity version 2020.3.8f1

    Quitting...
    Build.wasm:0x192e553 Uncaught RuntimeError: memory access out of bounds
    at _strlen (Build.wasm:0x192e553)
    at __ZN11NamedObject8TransferI19StreamedBinaryWriteEEvRT_ (Build.wasm:0x39626a)
    at __ZN6Avatar8TransferI19StreamedBinaryWriteEEvRT_ (Build.wasm:0x1ad3cb)
    at __ZN6Avatar23VirtualRedirectTransferER19StreamedBinaryWrite (Build.wasm:0x1a3ab8)
    at __ZN7ApiGLES17DeleteFramebufferERN2gl6HandleILNS0_10ObjectTypeE9EEES3_ (Build.wasm:0x35b8de)
    at __ZN18GfxFramebufferGLES18ReleaseFramebufferEP17RenderSurfaceBaseP14GfxContextGLES (Build.wasm:0x3627a7)
    at __ZN13GfxDeviceGLES28DestroyRenderSurfacePlatformEP17RenderSurfaceBase (Build.wasm:0x31787d)
    at __ZN9GfxDevice20DestroyRenderSurfaceER12ObjectHandleI17RenderSurface_TagP17RenderSurfaceBaseE (Build.wasm:0x31712f)
    at __ZN11ContextGLES22DeleteIntermediateFBOsEv (Build.wasm:0x365c10)
    at __ZN11ContextGLES7DestroyEv (Build.wasm:0x385573)
    at __ZN13GfxDeviceGLESD2Ev (Build.wasm:0x312f7e)
    at __Z16DestroyGfxDevicev (Build.wasm:0x4d0315)
    at __Z13CleanupEnginev (Build.wasm:0x4bf45b)
    at __Z13PlayerCleanupb (Build.wasm:0x4aea69)
    at __ZL8MainLoopv (Build.wasm:0x4ae862)
    at __Z28MainLoopUpdateFromBackgroundPv (Build.wasm:0x4d77bf)
    at dynCall_vi (Build.wasm:0x195205c)
    at Build.framework.js:28586:37
    at dynCall (Build.framework.js:375:35)
    at dynCall_wrapper (Build.framework.js:358:12)
    at wrapper (Build.framework.js:3373:29)
    at Build.framework.js:9724:5
     
  6. Guillaume-atVolumiq

    Guillaume-atVolumiq

    Joined:
    Sep 14, 2018
    Posts:
    36
    Still getting JS memory piling up on 2021.2.0f1
    Very annoying issue for us since our solution is supposed to be stopped and reopened often as a Vue/Angular component.


    Code (JavaScript):
    1. window.gameInstance.Quit().then(()=>{
    2.         window.gameInstance = null;
    3.       });
     
    Weidz_ and vb2s360 like this.
  7. LoneGoat

    LoneGoat

    Joined:
    Dec 16, 2020
    Posts:
    21
    I'm getting exactly this. I was hoping using OpenURL("pageUrl") would refresh the page, thus unloading the player but this is not so. Application.Quit() just seems to freeze the Player forcing a page refresh to unload anyways.

    What does work is:

    Application.ExternalEval("window.open('http://forum.unity.com/','_self')");


    Bring your own URL.
     
  8. DMG_GLein

    DMG_GLein

    Joined:
    Oct 4, 2021
    Posts:
    3
    We have the same problem as @Guillaume-atVolumiq. Our application is designed to be able to close and re-open the 3D WebGL viewport and there are two problems for us:

    We are currently on 2021.1, Unity quits as expected - see attachment.
    BUT Memory is not freed. Also tried all ideas from this thread - especially having the Chrome Developer Tools closed etc. But nothing helps in clearing the memory. And of course in JS setting the unity instance to NULL.

    Additionally, in 2021.2.19 and the new LTS 2021.3.2, we have the problem that Unity runs into an error on Quit and then gets caught in a loop, trying to quit but failing. See attached image.

    Anyone else seeing these? For us, opening a new tab is not the way to go.
     

    Attached Files:

  9. Guillaume-atVolumiq

    Guillaume-atVolumiq

    Joined:
    Sep 14, 2018
    Posts:
    36
    Yep getting the error loop here aswell.
     
    TDF_Marwan and scott1984 like this.
  10. DaveA_VR

    DaveA_VR

    Joined:
    May 26, 2022
    Posts:
    33
    Late to the party, but couldn't you implement a public 'Quit()' function, and then call that from your external JS before trying to free up the container?

    Code (CSharp):
    1. public class WebGLController
    2. {
    3.   public void Quit()
    4.   {
    5.     Application.Quit();
    6.   }
    7. }
     
  11. Guillaume-atVolumiq

    Guillaume-atVolumiq

    Joined:
    Sep 14, 2018
    Posts:
    36
    I've actually tested that already but the browser memory footprint stays the same.
     
  12. uwdlg

    uwdlg

    Joined:
    Jan 16, 2017
    Posts:
    142
    Is there a working way to quit a WebGL instance and clean up memory by now?
    I found an older post suggesting to use (and remove) an iframe as a possible workaround. But I would love to hear if someone maybe got a combination of Unity version and Quit() to work before testing that.
     
  13. susuxiaoming

    susuxiaoming

    Joined:
    Jun 14, 2022
    Posts:
    2
    i find 2022.3.1 fixes this, but call unityInstance.Quit() still not working.
    upload_2023-8-1_16-54-40.png
     

    Attached Files:

  14. susuxiaoming

    susuxiaoming

    Joined:
    Jun 14, 2022
    Posts:
    2
    ;)Have you checked further on the latest version? 2021LTS and 2022LTS
     
  15. ErrorX

    ErrorX

    Joined:
    May 21, 2014
    Posts:
    22
    Looks like they're not going to fix it:
    Issue: https://issuetracker.unity3d.com/is...ity-instance-with-decompress-fallback-enabled


    RESOLUTION NOTE:

    Thank you for reporting a bug to Unity.

    We have reviewed the issue carefully, and in this case, the team is unable to prioritize fixing this bug. There are a number of reasons we make this decision, including the impact and severity of the issue across our user and customer base, and the possibility that future plans may solve the problem in a different way, or that a workaround for the bug may be available.

    Today we will be closing this case. Thank you again for taking the time to report this issue, and please let us know if there is anything else that changes the impact or severity of this issue.
     
    Guillaume-atVolumiq likes this.