Bug 152416
Summary: | Web Inspector: WebInspector.dispatchNextQueuedMessageFromBackend leaks | ||
---|---|---|---|
Product: | WebKit | Reporter: | Nikita Vasilyev <nvasilyev> |
Component: | Web Inspector | Assignee: | Nikita Vasilyev <nvasilyev> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | bburg, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer |
Priority: | P2 | ||
Version: | WebKit Local Build | ||
Hardware: | All | ||
OS: | All | ||
Bug Depends on: | |||
Bug Blocks: | 152220 |
Nikita Vasilyev
Run the following HTML for 1 minute:
<script>
setInterval(function() {
console.info(Math.random())
}, 1);
</script>
After 1 minute, Web Inspector becomes unresponsive, even when the console tab was never opened.
https://github.com/WebKit/webkit/blob/master/Source/WebInspectorUI/UserInterface/Protocol/MessageDispatcher.js#L29
I added the following code at the bottom of dispatchNextQueuedMessageFromBackend:
console.info(i, WebInspector._messagesToDispatch.length - 1)
I showed:
4 145
4 141
4 137
4 260
4 256
4 252
...
After a minute:
3 6855
3 6852
3 6892
3 6920
3 6917
3 6951
3 6976
...
And another minute:
3 22495
3 22589
3 22684
2 22803
3 22907
...
WebInspector.dispatchNextQueuedMessageFromBackend isn't keeping up with the influx of messages.
It processes messages at a slower pace than they are being added, making Web Inspector UI unresponsive.
It is possible that on a fast machine such as Mac Pro this leak wouldn't even happen.
On a slow machine this leaks very fast.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Nikita Vasilyev
If WebKit implements requestIdleCallback we should consider using it.
https://developers.google.com/web/updates/2015/08/using-requestidlecallback?hl=en
Request to implement: https://lists.webkit.org/pipermail/webkit-dev/2015-September/027656.html
Blaze Burg
(In reply to comment #0)
> Run the following HTML for 1 minute:
>
> <script>
> setInterval(function() {
> console.info(Math.random())
> }, 1);
> </script>
>
> After 1 minute, Web Inspector becomes unresponsive, even when the console
> tab was never opened.
>
> https://github.com/WebKit/webkit/blob/master/Source/WebInspectorUI/
> UserInterface/Protocol/MessageDispatcher.js#L29
>
> I added the following code at the bottom of
> dispatchNextQueuedMessageFromBackend:
>
> console.info(i, WebInspector._messagesToDispatch.length - 1)
>
> I showed:
>
> 4 145
> 4 141
> 4 137
> 4 260
> 4 256
> 4 252
> ...
>
> After a minute:
>
> 3 6855
> 3 6852
> 3 6892
> 3 6920
> 3 6917
> 3 6951
> 3 6976
> ...
>
> And another minute:
>
> 3 22495
> 3 22589
> 3 22684
> 2 22803
> 3 22907
> ...
>
> WebInspector.dispatchNextQueuedMessageFromBackend isn't keeping up with the
> influx of messages.
> It processes messages at a slower pace than they are being added, making Web
> Inspector UI unresponsive.
>
I don't think there's anything wrong with WebInspector.dispatchNextQueuedMessageFromBackend. It's not leaking any memory. If backend messages were to stop, it would eventually drain the message queue. The problem is that the console code is extremely intertwined with the DOM, so it takes (relatively) forever to process a console log message. There is nothing that this code could do differently to fix the problem (without introducing bigger problems).
> It is possible that on a fast machine such as Mac Pro this leak wouldn't
> even happen.
> On a slow machine this leaks very fast.