Pass property style map cross thread |
||
Issue descriptionIn the CSSPaintDefinition::Paint, we create a PrepopulatedComputedStylePropertyMap and call ToV8 on that. We cannot safely pass the PrepopulatedComputedStylePropertyMap cross thread because it has a hashmap from AtomicString to CSSValue. In this CL: https://chromium-review.googlesource.com/c/chromium/src/+/1281702 I tried to replace the PrepopulatedComputedStylePropertyMap with a PaintWorkletStyleMap which keeps a hashmap from WTF::String to CSSStringValue. This works fine if we are just doing styleMap.get('--foo').toString(). But doesn't work for this use case: https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/external/wpt/css/css-paint-api/paint2d-image.https.html We have to think about how to pass the style map cross thread properly, specially for the CSSImageValue case where it keeps a StyleImage.
,
Oct 15
,
Oct 15
So a few half baked thoughts - Passing newly created CSSValues should be thread safe? I believe OffscreenCanvas did work to make sure this works. But I might be wrong. - If you pass HashMap<String, const CSSValue> HashMap<CSSPropertyID, const CSSStyle> it might be worth refactoring PrepopulatedStylePropertyMap to take these in the ctor, and moving other logic out(?). Maybe? - In the bundle converting from/to String->AtomicString seems like the best approach? - Images are only slightly working at the moment, and need to be fixed. There might be a better approach to the CSSImageValue than storing a CSSValue with a StyleImage.
,
Oct 16
ikilpatrick@: I don't recall how OffscreenCanvas sets the property. I think it sets the property on the HTMLCanvas that is backing the OffscreenCanvas?
,
Oct 16
OffscreenCanvas uses CSSValues internally for things like: ctx.filter = 'blur(2px)'; // triggers CSS Parser ctx.font = 'Arial 20px'; // same again etc. e.g. https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc?q=base_rendering_con&sq=package:chromium&g=0&l=423
,
Oct 16
Ah, I see. Yeah, I had a discussion with flackr@, and it seems that to make it work for us, we need to somehow "serialize" the CSSValue, pass its type (like ColorValue), and everything that is needed to rebuild that ColorValue on the worklet thread. Does that make sense?
,
Nov 29
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35 commit 0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35 Author: Xida Chen <xidachen@chromium.org> Date: Thu Nov 29 16:00:05 2018 Make StylePropertyMapReadOnly a pure interface This CL is implementing the Phase 1 described in this doc: https://docs.google.com/document/d/1v-k8Ck7x_2kpBfgaVmqg2NvQRvD1PqyOt50rdO141Wc/edit# Basically, it redefines the StylePropertyMapReadOnly to be a pure interface. Then it renames the existing StylePropertyMapReadOnly to StylePropertyMapReadOnlyMainThread. Then it makes all subclasses of StylePropertyMapReadOnly to be subclasses of StylePropertyMapReadOnlyMainThread. This CL should not introduce any behavior change. Bug: 895579 Change-Id: I400981d1745ab3ee80b9ba9b77c3e3406cd0c1e7 Reviewed-on: https://chromium-review.googlesource.com/c/1354118 Commit-Queue: Xida Chen <xidachen@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/master@{#612216} [modify] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/BUILD.gn [modify] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/computed_style_property_map.h [modify] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.cc [modify] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/prepopulated_computed_style_property_map.h [modify] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/style_property_map.h [modify] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/style_property_map_read_only.h [rename] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.cc [add] https://crrev.com/0a7ee900622bdbaa22f2ca4cbdb06da7ca9dcc35/third_party/blink/renderer/core/css/cssom/style_property_map_read_only_main_thread.h
,
Today
(14 hours ago)
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/cc7370403a6e6bbbf2178573239797a566a342a4 commit cc7370403a6e6bbbf2178573239797a566a342a4 Author: Xida Chen <xidachen@chromium.org> Date: Tue Jan 22 18:13:28 2019 [OT-PW] Create a PaintWorkletStyleValue This is a start of the implementation described in this doc: https://docs.google.com/document/d/1v-k8Ck7x_2kpBfgaVmqg2NvQRvD1PqyOt50rdO141Wc/edit#heading=h.4bikug2pvlqa In a high-level, we will be putting a HashMap<String, std::unique_ptr<CrossThreadStyleValue>> in the PaintWorkletStylePropertyMap, which can be safely passed cross threads, and the PaintWorkletStyleValue can be easily converted to CSSStyleValue which is eventually what we need on the worklet thread. Bug: 895579 Change-Id: I986b0efc43611bc0989a9ff6d7a009fa77ba2124 Reviewed-on: https://chromium-review.googlesource.com/c/1412037 Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Xida Chen <xidachen@chromium.org> Cr-Commit-Position: refs/heads/master@{#624833} [modify] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl [modify] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/BUILD.gn [modify] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/BUILD.gn [add] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/cross_thread_style_value.h [add] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/cross_thread_style_value_test.cc [add] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.cc [add] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.h [modify] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.cc [modify] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map.h [modify] https://crrev.com/cc7370403a6e6bbbf2178573239797a566a342a4/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc |
||
►
Sign in to add a comment |
||
Comment 1 by flackr@chromium.org
, Oct 15