Bug 202574

Summary: Implement [Transferable] property of OffscreenCanvas
Product: WebKit Reporter: Chris Lord <clord>
Component: CanvasAssignee: Chris Lord <clord>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, alecflett, beidson, cdumez, commit-queue, darin, dbates, dino, esprehn+autocc, ews-watchlist, ggaren, gyuyoung.kim, jiewen_tan, jsbell, kangil.han, koivisto, mmaxfield, rniwa, sabouhallawa, sam, simon.fraser, webkit-bug-importer, ysuzuki, zan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 202573, 205385    
Bug Blocks: 183720, 202797    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
again
none
Patch
none
Patch none

Attachments
Patch (36.50 KB, patch)
2019-10-10 04:09 PDT, Chris Lord
no flags
Patch (41.60 KB, patch)
2019-12-16 02:30 PST, Chris Lord
no flags
Patch (42.05 KB, patch)
2019-12-18 04:19 PST, Chris Lord
no flags
Patch (40.18 KB, patch)
2019-12-18 05:38 PST, Chris Lord
no flags
Patch (39.05 KB, patch)
2020-01-28 03:00 PST, Chris Lord
no flags
again (6.55 KB, patch)
2020-01-28 06:36 PST, Antti Koivisto
no flags
Patch (40.20 KB, patch)
2020-01-28 08:54 PST, Chris Lord
no flags
Patch (40.20 KB, patch)
2020-01-28 09:20 PST, Chris Lord
no flags
Chris Lord
Comment 1 2019-10-10 04:09:11 PDT
Chris Lord
Comment 2 2019-12-16 02:30:09 PST
Sam Weinig
Comment 3 2019-12-16 11:27:51 PST
Comment on attachment 385745 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=385745&action=review > Source/WebCore/html/OffscreenCanvas.cpp:284 > + return std::unique_ptr<DetachedOffscreenCanvas>(new DetachedOffscreenCanvas(takeImageBuffer(), size(), originClean())); Please use makeUnique<>
Ryosuke Niwa
Comment 4 2019-12-16 13:41:48 PST
Comment on attachment 385745 [details] Patch r- due to build failures.
Chris Lord
Comment 5 2019-12-18 04:19:00 PST
Chris Lord
Comment 6 2019-12-18 04:25:56 PST
argh, I think I've missed some OffscreenCanvas guards, will fix...
Chris Lord
Comment 7 2019-12-18 05:38:13 PST
Chris Lord
Comment 8 2019-12-18 06:10:05 PST
I don't think the style test will pass without reformatting a not-trivial amount of the affected file - note, my additions are in keeping with what's in the file already.
Chris Lord
Comment 9 2020-01-28 03:00:16 PST
Antti Koivisto
Comment 10 2020-01-28 06:26:54 PST
Comment on attachment 388978 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=388978&action=review > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3153 > +#if ENABLE(OFFSCREEN_CANVAS) > + { }, > +#endif > #if ENABLE(WEBASSEMBLY) > nullptr, > #endif Maybe CloneDeserializer could have default argument values to avoid these? > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3574 > return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobURLs, nullptr, nullptr, { } > +#if ENABLE(OFFSCREEN_CANVAS) > + , { } > +#endif > #if ENABLE(WEBASSEMBLY) > , nullptr > #endif Maybe SerializedScriptValue could have default argument values to avoid these? > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3589 > +static bool offscreenCanvasesCanDetach(const Vector<RefPtr<OffscreenCanvas>>& offscreenCanvases) The usual style is to start boolean functions with verb like is/are/has etc., maybe areAllOffscreenCanvasesDetachable or something like that. > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3596 > + if (!visited.add(offscreenCanvas.get())) > + return false; What is this test about? Maybe add a comment?
Antti Koivisto
Comment 11 2020-01-28 06:36:17 PST
Antti Koivisto
Comment 12 2020-01-28 06:43:01 PST
Comment on attachment 388986 [details] again oops wrong bug
Chris Lord
Comment 13 2020-01-28 08:54:23 PST
Chris Lord
Comment 14 2020-01-28 09:20:13 PST
WebKit Commit Bot
Comment 15 2020-01-28 14:48:11 PST
Comment on attachment 389015 [details] Patch Clearing flags on attachment: 389015 Committed r255315: <https://trac.webkit.org/changeset/255315>
WebKit Commit Bot
Comment 16 2020-01-28 14:48:14 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 17 2020-01-28 14:49:18 PST
Darin Adler
Comment 18 2020-01-28 16:55:04 PST
Comment on attachment 389015 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=389015&action=review > Source/WebCore/bindings/js/SerializedScriptValue.cpp:567 > static SerializationReturnCode serialize(JSGlobalObject* lexicalGlobalObject, JSValue value, Vector<RefPtr<MessagePort>>& messagePorts, Vector<RefPtr<JSC::ArrayBuffer>>& arrayBuffers, const Vector<RefPtr<ImageBitmap>>& imageBitmaps, > +#if ENABLE(OFFSCREEN_CANVAS) > + const Vector<RefPtr<OffscreenCanvas>>& offscreenCanvases, > +#endif > #if ENABLE(WEBASSEMBLY) > WasmModuleArray& wasmModules, > #endif > Vector<String>& blobURLs, Vector<uint8_t>& out, SerializationContext context, ArrayBufferContentsArray& sharedBuffers) Seems to me that long arguments lists like these with compiler-conditioonal arguments in them are not a great pattern. We should look for something more elegant and easy to read. Maybe a structure would help in some way? > Source/WebCore/bindings/js/SerializedScriptValue.cpp:969 > + void dumpOffscreenCanvas(JSObject* obj, SerializationReturnCode& code) WebKit coding style says use a word here, object, not an abbreviation, obj. Also, we like to use references for things that can’t be null. Although I guess JavaScript programmers are holdouts on that one? > Source/WebCore/bindings/js/SerializedScriptValue.cpp:3595 > + Vector<RefPtr<OffscreenCanvas>> offscreenCanvases; I’d think Vector<Ref> would be the right type for these vectors. Seems unlikely we need to store nulls in them. > Source/WebCore/bindings/js/SerializedScriptValue.h:52 > +#if ENABLE(OFFSCREEN_CANVAS) > +class DetachedOffscreenCanvas; > +#endif Two coding style thoughts: 1) I’m not sure it’s worthwhile to put forward declarations inside #if blocks. I think it’s probably a reasonable practice to define them even if they aren’t used. 2) If we are going to put them in #if blocks, then the #if block should be a separate paragraph and not interspersed with other forward declarations. This is the same rule we follow for includes. > Source/WebCore/html/OffscreenCanvas.cpp:90 > + if (m_detached) > + return 0; Can we just set m_size to 0 as part of the detaching process? Then we can let width remain a non-virtual function. > Source/WebCore/html/OffscreenCanvas.cpp:97 > + if (m_detached) > + return 0; Ditto.
Note You need to log in before you can comment on or make changes to this bug.