Bug 183720 - Complete OffscreenCanvas implementation
Summary: Complete OffscreenCanvas implementation
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Lord
URL:
Keywords:
Depends on: 180833 186759 197421 202525 202574 202793 202794 202797 202798 204575 179191 182503 182685 182686 182921 183440 202394 202513 202572 202573 203146
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-17 00:48 PDT by Zan Dobersek
Modified: 2019-11-25 06:56 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2018-03-17 00:48:36 PDT
SSIA.
Comment 1 Sanjay Kumar 2019-07-20 06:56:57 PDT
Is this planed for near future?

Since webkit does not support Webp, OffscreenCanvas is the only performant way to convert such images on a background thread. Not having Offscreen canvas means no Webp (or any other image format not supported y Safari).

OffScreen canvas will also enables mapping engines such as Mapbox to render tiles on background threads - significantly speeding up maps.

It would be great if Webkit were to implement Offscreen canvas - it will unlock huge potential for the web.

Thank you for considering it a priority.
Comment 2 Chris Lord 2019-08-22 08:37:29 PDT
I'm working on updating/finishing Zan's patches.
Comment 3 Chris Lord 2019-09-19 09:29:37 PDT
Just to note that I'm still working on this, and my current work is available on GitHub here: https://github.com/Cwiiis/webkit/tree/offscreen-canvas

Many tests are passing and the 2d functionality is fairly complete, but there's still a fair amount of work to tidy it up and start submitting patches for review. I expect some of the choices I've made will need to be inspected and re-thought by people with more knowledge of the code-base.
Comment 4 Myles C. Maxfield 2019-10-10 11:33:53 PDT
Finishing OffscreenCanvas support with 2D rendering would be a fantastic addition to WebKit! Thanks for working on it! The WebKit team at Apple would be happy to help and answer any questions you have. We're really looking forward to seeing this happen!
Comment 5 Simon Fraser (smfr) 2019-10-10 11:49:21 PDT
One note of caution: it's going to be very hard for us to verify, via review, that you'd done all the correct locking to make off-main-thread canvas drawing, and all the called code (text, fonts, images etc) thread-safe. Anything you can do to convince us that you got it right will help with review. "I added some locking and it seems to work" won't be entirely convincing :)
Comment 6 Chris Lord 2019-10-11 01:49:19 PDT
(In reply to Simon Fraser (smfr) from comment #5)
> One note of caution: it's going to be very hard for us to verify, via
> review, that you'd done all the correct locking to make off-main-thread
> canvas drawing, and all the called code (text, fonts, images etc)
> thread-safe. Anything you can do to convince us that you got it right will
> help with review. "I added some locking and it seems to work" won't be
> entirely convincing :)

This is absolutely fair :) I've been making sure that all tests run in debug mode (there are a *lot* of thread-related asserts), but really I'm not sure how to best fully guarantee this. I'm reasonably confident that it's only the font bits that are worrisome...

Do you have any suggestions beyond relying on tests? Assuming we can get to the point where everyone is happy that there aren't any obvious concurrency issues, is this something we could land (perhaps disabled on release by default? What's the best way to go about that?) to increase testing?
Comment 7 Ashley Gullen 2019-11-25 06:56:56 PST
I'd like to point out that user gesture requirements equivalent to Chrome's "User Activation v2" are important for some OffscreenCanvas use cases. In our case we can host our entire game engine in a web worker, forwarding input events over postMessage, and posting back for certain DOM APIs not available in workers (e.g. requestFullscreen). If user activation is limited to synchronous callbacks in input events, this blocks the use of any input-restricted APIs (like requestFullscreen), which would block our use of OffscreenCanvas. With User Activation v2, the restrictions are relaxed enough that it keeps working and means we can use OffscreenCanvas. I'm not sure what the status of user gestures are in WebKit but it might be worth reviewing this for OffscreenCanvas.