Discussion:
[chromium-dev] Offscreen canvas worker and postMessage priority
Raanan
2018-10-17 11:12:05 UTC
Permalink
Hi,
I use a Worker to do OffscreenCanvas rendering, and return a transferable
ImageBitmap to the main thread. Chrome 69.0.3497.100 (64 bit).
I see that the total time on main (from posting to the worker till
receiving the bitmap) is much larger than the combined times of postMessage
(serialization) and the worker processing time (till the return postMesage).

For example: numbers I see are (in ms):
mainTotal:73.4 mainPost:0.5 workerTotal:0.6
mainTotal:300.3 mainPost:0.9 workerTotal:1.2

I suspect the returned message from the worker spends this extra time in
the event loop queue on main thread until the onMessage is fired, since
meanwhile I process mouse events on the main thread. The other source
could be that the postMessage from the worker is slow, but since it is
basically just a transferable I think its not the issue.

My questions:
1. Could it be that the mouse event messages have a higher priority than
the worker return messages, and so are processed before the worker return
message even if they came after?
2. If so, is there a way to control the priority of the worker return
message? I prefer to draw as soon as the imageBitmap is ready

Thanks,
Raanan
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/220ff38c-a5ff-47b1-8786-683d3c5e5f5c%40chromium.org.
Fernando Serboncini
2018-10-17 11:38:43 UTC
Permalink
You don't need to "transferToImageBitmap" to use OffscreenCanvas on workers.

If you are just trying to render to a canvas on the document from a Worker,
use "canvas.transferControlToOffscreen()" and pass the returned
OffscreenCanvas to the Worker. In this way, the OffscreenCanvas will
automatically "transfer" the render for you, so there's no need to
postMessage.

Does that solve your problem?
Post by Raanan
Hi,
I use a Worker to do OffscreenCanvas rendering, and return a transferable
ImageBitmap to the main thread. Chrome 69.0.3497.100 (64 bit).
I see that the total time on main (from posting to the worker till
receiving the bitmap) is much larger than the combined times of postMessage
(serialization) and the worker processing time (till the return postMesage).
mainTotal:73.4 mainPost:0.5 workerTotal:0.6
mainTotal:300.3 mainPost:0.9 workerTotal:1.2
I suspect the returned message from the worker spends this extra time in
the event loop queue on main thread until the onMessage is fired, since
meanwhile I process mouse events on the main thread. The other source
could be that the postMessage from the worker is slow, but since it is
basically just a transferable I think its not the issue.
1. Could it be that the mouse event messages have a higher priority than
the worker return messages, and so are processed before the worker return
message even if they came after?
2. If so, is there a way to control the priority of the worker return
message? I prefer to draw as soon as the imageBitmap is ready
Thanks,
Raanan
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups
"Chromium-dev" group.
To view this discussion on the web visit
https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/220ff38c-a5ff-47b1-8786-683d3c5e5f5c%40chromium.org
<https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/220ff38c-a5ff-47b1-8786-683d3c5e5f5c%40chromium.org?utm_medium=email&utm_source=footer>
.
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CADp2-T9rXTPAK6_TOcnrE5wGhb7mnXAZhQ7fJx5qz5Bnb1kUJQ%40mail.gmail.com.
Raanan
2018-10-17 11:54:46 UTC
Permalink
Thanks Fernando!
It doesn't solve my problem, the reason I transfer back is because I need
to sync the render of that bitmap with other elements/canvases in the same
animation frame
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/50f89b6b-aa0e-4040-a027-e63e483d1028%40chromium.org.
Fernando Serboncini
2018-11-06 18:47:50 UTC
Permalink
if this is still an issue, please open a bug at crbug.com and assign to me
please.
Post by Raanan
Thanks Fernando!
It doesn't solve my problem, the reason I transfer back is because I need
to sync the render of that bitmap with other elements/canvases in the same
animation frame
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups
"Chromium-dev" group.
To view this discussion on the web visit
https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/50f89b6b-aa0e-4040-a027-e63e483d1028%40chromium.org
<https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/50f89b6b-aa0e-4040-a027-e63e483d1028%40chromium.org?utm_medium=email&utm_source=footer>
.
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CADp2-T_b5EOznQOBKVPFYoRo59rUvkqCzWYr%3DpTcKbLijZGPqg%40mail.gmail.com.
Loading...