Web Worker debugging

768 views
Skip to first unread message

Daniel Simpson

unread,
Sep 13, 2018, 8:53:08 AM9/13/18
to Chrome DevTools
Hello,

I have written a web worker that does some relatively heavy file decoding and sends data back to the main thread. This works and is very fast in Firefox (an example file of 234MB takes about 40 seconds) but in Chrome after 40 seconds it has maybe done about 5% of the file. So, naturally, I go to profile this in the performance tab of DevTools to see why it's so much slower but as soon as I choose the file to decode and the worker starts the DevTools crashes with "DevTools was disconnected from the page" and I have to reload the page.

I have no idea where to go from here, any guidance is greatly appreciated.

Windows 10
Version 69.0.3497.92 (Official Build) (64-bit)

Thanks,
Daniel.

Daniel Simpson

unread,
Sep 14, 2018, 8:53:27 AM9/14/18
to Chrome DevTools
Sorry, I solved it. For people facing the same issue as this here is how I diagnosed it and how I solved it. Not sure why I had the problem in the first place though.

I tested it in Edge and it was just as slow as Chrome but I was able to profile it in Edge and saw that it was idle 99.6% of the time, which was strange because there's an infinite loop until the file is completely parsed. From an older version of the codebase I had a setTimeout with a time of 0 for the infinite loop, so I changed this to a while (true) and this completely fixed the slowness issue. So, for some reason a setTimeout 0 inside a web worker in both Chrome and Edge is extremely slow but in Firefox it's fast.

Thanks.

David Wakelin

unread,
Sep 14, 2018, 9:03:40 AM9/14/18
to google-chrome-...@googlegroups.com
Hi Daniel,

Both Firefox and Chrome throttle setTimeout for performance reasons.

Either Edge has a different work around or they let their users suffer from poorly designed webpages.

Kind Regards
David Wakelin

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/9bff9b0a-6e97-439b-8679-eb6d5eeaeca4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages