NEW267391
Memory Leak on pages running a WebGL context
https://bugs.webkit.org/show_bug.cgi?id=267391
Summary Memory Leak on pages running a WebGL context
diachenko.tetiana
Reported 2024-01-10 18:58:30 PST
Created attachment 469364 [details] 1 - HTML page memory use I was looking into a memory issue with a company project (Unity WebGL) that was only occurring on iPhones and after running several profiling sessions with Safari Devtools Timelines, I arrived at the conclusion that this is likely a memory leak on the WebKit side. Here is a brief summary of the initial issue and approaches I've attempted before arriving at this conclusion: The original issue is that the web page would automatically reload a couple of minutes after player character spawned within the game. Knowing that automatic page reloads on iPhone are usually caused by high memory use, I first checked for memory leaks in our project. Taking multiple memory snapshots (after load, 5, 10, 15, 20 minutes later) using unity memory profiler from an autoconnected development build didn't indicate any memory leaks. I then moved on to using Safari Devtools Timelines to get more data about the issue. Connecting the iPhone to a macBook and running a few profiling sessions I could see a slow and steady increase in memory use over time, primarily - what Timelines categorizes as "Page" memory. I thought there might be a chance that the increase I see on the graph - is just extra memory, that is being used by the profiler itself, so I run the same experiment on a few different pages (see attachments): 1) On a simple web-page (only HTML, CSS, JS) the memory usage stayed pretty much constant for the full 10 minutes I was running the profiling session. 2) On another company project (made with PlayCanvas) - "Page" memory usage grew ~2.5x over the 10 minute profiling session 3) On the page of the project where the issue first occured - "Page" memory usage also grew ~2.5x over the 10 minute profiling session Based on this data I came to the conclusion that it is likely a WebKit issue. If I am mistaken, any insight into alternative causes would be much appreciated.
Attachments
1 - HTML page memory use (390.79 KB, image/png)
2024-01-10 18:58 PST, diachenko.tetiana
no flags
2 - Play Canvas page memory use (453.87 KB, image/png)
2024-01-10 18:59 PST, diachenko.tetiana
no flags
3 - Unity WebGL page memory use (374.25 KB, image/png)
2024-01-10 18:59 PST, diachenko.tetiana
no flags
Minimal WebGL demo (594 bytes, text/html)
2024-01-14 20:21 PST, diachenko.tetiana
no flags
diachenko.tetiana
Comment 1 2024-01-10 18:59:21 PST
Created attachment 469365 [details] 2 - Play Canvas page memory use
diachenko.tetiana
Comment 2 2024-01-10 18:59:59 PST
Created attachment 469366 [details] 3 - Unity WebGL page memory use
Alexey Proskuryakov
Comment 3 2024-01-11 08:44:53 PST
Thank you for the report. Could you please provide a way for us to reproduce this issue?
diachenko.tetiana
Comment 4 2024-01-14 20:21:12 PST
Not sure how much access to the project used for reproducing the bug, and since I cannot share source code of company project - I checked and confirmed that the issue also occurs on one of Unity's publicly available demo's. Here is the link to the repository: https://github.com/Unity-Technologies/BoatAttack And here is the link to a hosted demo: https://boat-demo.cds.unity3d.com/ To reproduce the issue, you can visit the demo above, open Safari developer tools, press "Record" on the Timelines tab with the Memory Instrument turned on and observe "Page" memory increase over time. I also tried to reproduce the issue with a very minimal static page, that creates a WebGL2.0 context via a JS script. The page memory did increase, but only by about 0.06 MB over 10 minutes, so I am not sure how relevant that data is. Regardless, I will attach the HTML file to this ticket just in case and leave the relevance of this information to your discretion.
diachenko.tetiana
Comment 5 2024-01-14 20:21:42 PST
Created attachment 469400 [details] Minimal WebGL demo
Radar WebKit Bug Importer
Comment 6 2024-01-17 18:59:17 PST
Note You need to log in before you can comment on or make changes to this bug.