Hi all,
This is a discussion thread about the internal implementation of canvas.toBlob. Basically, we've implemented two different versions of image encoding within the toBlob function:
1) threaded implementation: opens up a separate thread that accomplishes the asynchronous image encoding task continuously and the thread is shared among all canvases
2) idle-periods implementation: performs the image encoding task incrementally and fit in the task into the idle periods on the main thread
I had repeatedly tried experiments of both idle-periods implementation and threaded implementation for png image encoding on a variety of perf trybots (data available here: https://docs.google.com/a/google.com/spreadsheets/d/18LKHE3pV262hd4DCEw4k4MtMowwyaUXCxhkOCOXt1_0/edit?usp=sharing). As a summary, we measured both the toBlob duration, as well as the impact of toBlob on the smoothness of animation (i.e. whether it causes jankiness).
Experimentally, we find that:
--
You received this message because you are subscribed to the Google Groups "paint-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paint-dev+...@chromium.org.
To post to this group, send email to pain...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/paint-dev/CADojJpDdvezopYe5ZdsA-GtJzf2%3DKh2AGyh8ngN5wqKBMQbxfg%40mail.gmail.com.
Is there a plan to move to a thread pool or similar approach long term? I think Chromium uses thread pools for similar cases, and I'm not sure we'll want to have an unterminating thread for each off-thread feature we add in the future.
Using a thread means you're contending with all the other threads, in a real app that includes the parser thread, v8 compiler, GC threads, workers, service workers, compositor, raster threads, and more.
I believe it looks faster in small benchmarks, but I bet you're just causing descheds in busy apps to win the race. Oilpan did this too, at first they just used more threads to look amazing on some benchmarks. :)
Ex. Raster tasks are likely more important than these tasks, but you probably bump them off the cores.
Please don't add a new unterminating thread.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/paint-dev/CABpaAqTr5e1jNfnRzvgmJ4de2urg4-y_-R-iwB_Yy9CFj9vO0w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/paint-dev/CAO9Q3iJctkfp0DhgT3WsToT-LZ3wtv26AvrZ5JQuj8DijqhxNQ%40mail.gmail.com.
First of all, ideally if we have a shared thread pool for Blink, the threaded implementation will become the most suitable implementation; but now we don't have it; and we cannot keep waiting for the shared thread pool to be ready and let that block shipping this important function in canvas.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/scheduler-dev/CADHjF%2BHd8U46zeefiMnDczmR7uuk-hz%3D9gnDhVmLr_UzZ90Qqg%40mail.gmail.com.You received this message because you are subscribed to the Google Groups "scheduler-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheduler-de...@chromium.org.
To post to this group, send email to schedu...@chromium.org.
2015-12-03 20:14 GMT+00:00 xlai <xl...@chromium.org>:First of all, ideally if we have a shared thread pool for Blink, the threaded implementation will become the most suitable implementation; but now we don't have it; and we cannot keep waiting for the shared thread pool to be ready and let that block shipping this important function in canvas.If we do decide to go the threaded route, I don't exposing a shared thread pool to Blink would necessarily be all that complicated. The simplest way would be to have a function like blink::Platform::backgroundThreadPoolTaskRunner() which routes tasks into base::WorkerPool (like we already do for v8).
Yes, sounds interesting. If the user was doing back-to-back toBlob calls on the same <canvas> say, processing their video frames maybe, this would queue their toBlob calls FIFO order on a single thread pool? Is that the idea?What happens to all that (assumed) queued background toBlob work when the user navs the page?
~noel
Using a thread means you're contending with all the other threads, in a real app that includes the parser thread, v8 compiler, GC threads, workers, service workers, compositor, raster threads, and more.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/paint-dev/CAO9Q3iJctkfp0DhgT3WsToT-LZ3wtv26AvrZ5JQuj8DijqhxNQ%40mail.gmail.com.
Thanks Tim,Olivia and I discussed this, and we think the exposing the shared thread pool to blink and using it for toBlob is worth trying out, and comparing.
That being said I am not sure this fully addresses the concerns you are raising because to my knowledge, the shared thread pool does not yield to the compositor (and other high priority things), or does it?
Also, we'd like to improve our tests by making them truly tough. I agree with your concern that the test we were using may have been too easy (not threaded enough and/or not busy enough on the main thread). I am not sure how one would create a telemetry test that has multiple animated pages running at once. Do you know of scheduling tests we could use as inspiration?
Great, that matches my expectations as well. :)