Optimize silhouette readback canvas - #21
Conversation
|
do you have a benchmark - even a micro one - where this shows measurable improvement? |
|
I ran a microbenchmark that mirrors Chrome 149.0.7827.55 (headless, macOS):
So I do not have a measurable speed improvement to claim in this environment. The concrete effect is declaring the actual repeated-readback usage up front and avoiding Chrome's canvas readback heuristic warning in the downstream real-browser scenario. I also narrowed the PR in c69318a: the hint now applies only to Local lint, build, and unit tests pass. The old pinned Playwright Chromium integration binary could not launch on this macOS/Node environment ( |
|
i asked you not codex |
Use a readback-optimized Canvas2D context for the shared canvas used by
Silhouette.unlazy()during SVG/bitmap picking.Passing
willReadFrequently: trueat the canvas's initial context creation declares the repeatedgetImageData()usage up front and avoids Chromium's Canvas2D readback heuristic warning. Other renderer canvases, includingTextBubbleSkin, are unchanged.Microbenchmark (Chrome 149.0.7827.55 headless on macOS; shared 480×360 canvas; resize → drawImage → getImageData; median of 10 alternating rounds):
willReadFrequently: true: 26.6 ms / 100 iterationsThis benchmark does not show a measurable speed improvement, so the PR does not claim one.
Validation:
npm run lint: passnpm run build: passspawn Unknown system error -88)Downstream tracking: kubohiroya/tmpose-kamishibai#564