arl / statsviz

🚀 Visualise your Go program runtime metrics in real time in the browser
MIT License
3.19k stars 121 forks source link

Improve the problem of lagging or even OOM caused by reactivation after hanging in the background for a long time #120

Closed mzzsfy closed 8 months ago

arl commented 8 months ago

Hi and thank you for contributing Can you say a bit more about the issue and explain the solution you implemented to resolve it.

mzzsfy commented 8 months ago

When your page is in the background for a long time (minutes or even hours, Chrome), the callback of websocket.onmessage will not be processed on time. When the page is reactivated, onmessage is called repeatedly, which will generate a large number of UI redraw, which will cause the page to freeze or even OOM My solution is to separate the ui redrawing from the onmessage method and use the setInterval method to render the ui separately. When onmessage is called repeatedly, a large number of ui redrawing will not occur.

arl commented 8 months ago

I see, thank you very much.

mzzsfy commented 8 months ago

Nice, so when will this be released to the next version? I have encountered this problem many times. In the worst case, I need to use the task manager to forcefully close chrome.

arl commented 8 months ago

Nice, so when will this be released to the next version?

As soon as I've got the time to try your PR, merge it and tag a release. I hope to have time today, or else it's going to be during the weekend

mzzsfy commented 8 months ago

I see, thank you very much.

arl commented 8 months ago

I've tried to reproduce the problem you were having but I couldn't. Can you detail the steps needed to reproduce it please, by creating a new issue so it 'd be easier to keep track thank you?

mzzsfy commented 8 months ago

Windows systems,open web page, use Microsoft Edge and play the video in full screen. It will take about a few minutes to reproduce the problem(Make sure the energy -saving mode is not closed).If you still can't reproduce this scenario, I will submit an issue

mzzsfy commented 8 months ago

Already solved https://github.com/arl/statsviz/pull/122