Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Memory debugging on Safari?

Discussion in 'Web' started by De-Panther, Nov 16, 2022.

  1. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    We have a Unity WebGL project that we run on Safari.
    While checking performance issues using the memory timeline - https://webkit.org/blog/6425/memory-debugging-with-web-inspector/
    We noticed that the Page category is growing larger and larger, while all the others stay the same over time.

    One issue we had, was downloading too large images and not clearing some of them, we fixed it and it helped.
    But even after that, the Page category is still large and growing over time.

    What else can we check that goes to the Page category? I guess it's mainly WebGL objects, but I'm not sure which and how to debug it. Frame buffers? Meshes? Materials? Shaders? Shader variants?

    Also, we are currently using Unity 2020.3, does upgrading to 2021.3 should help, as it's using newer emscripten version? or it shouldn't be related?

    Thanks

    cc @brendanduncan_u3d
     
    gtk2k likes this.
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,507
    It certainly won't hurt giving it a try. Especially WebGL has seen many beneficial improvements (even if only under the hood) over the last couple years.

    With Page growing over time I'm instantly thinking garbage collection or memory leaks. Make sure the app running in the editor does not show the same memory consumption behaviour when analyzed with Unity's (memory) profiler. But if it does, it'll be easier to pinpoint and fix the issues from within the editor.
     
  3. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    If it was general memory leak, I would see the WASM Heap growing.
    The Page, as written in the link I shared, is "All other memory. This includes engine memory related to the DOM, styles, rendering data, memory caches, system allocations, etc."

    So I'm not sure if and which parts I would be able to debug in the editor profiler.
     
  4. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    458
    Is it just Safari having the memory problems? And it's not growing the WASM heap? If it was WebGL objects leaking, it would affect other browsers as well. The memory debugging tools in the browser are pretty opaque, especially Safari's. @unityruba recently made a tool for watching WASM heap growth, but I don't remember which Unity versions that went into. It would be possible to write some JS to track WebGL objects being created and destroyed, to see if that's where the leak is coming from. I can show you how you could do that, if it sounds useful. I'm not sure what other tools are available for Safari other than the built-in ones, which sometimes aren't that helpful
     
  5. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    It's not the WASM, the JS memory and the WASM Heap stay the same after init stages.

    It might be Safari only, or specific old version of Safari, but I tested different Unity experiences and some of them don't have this issue. So maybe even if it's Safari only, we can find a workaround.

    A way to track WebGL objects would be great.

    Thanks