Repository navigation
fix(apple): keep a cached canvas image's inline data alive - #737
Conversation
|
The diagnosis is right, but the reuse it works around is a real bug, not only a test artifact: Suggest fixing it in the cache instead: keep the source (or its |
ImageSource.Key names inline data by its address, and loadedImage did not keep the source, so once an app dropped a buffer, a new one of the same length at the same address got the old entry and a canvas drew the old picture. The entry now keeps its source, as Linux and Windows image slots do. This was also the cause of the TestCanvasImageCacheKeepsAWidePass flake. Fixes #715
798e9d3 to
c39b0fd
Compare
|
Reviewed independently. |
ImageSource.Key names inline data by its address, and the web canvas image cache did not keep the source, so a collected buffer's address could come back in a new buffer of the same length and be handed the old image, which the cache never evicts. The entry now keeps its source, as the Apple canvas cache does since nsgo-dev#737 and the Linux and Windows canvas image slots already did. Part of nsgo-dev#738
ImageSource.Key names inline data by its address, and the web canvas image cache did not keep the source, so a collected buffer's address could come back in a new buffer of the same length and be handed the old image, which the cache never evicts. The entry now keeps its source, as the Apple canvas cache does since #737 and the Linux and Windows canvas image slots already did. Part of #738
Summary
Fixes #715. Apple half of #738.
ImageSource.Keynames inline data by its backing address and length, and the Apple canvas image cache'sloadedImagedid not keep the source. Once an app dropped an inlineDatabuffer, a new buffer of the same length could land at the same address, get the old cache entry, and the canvas drew the old picture with no error. The entry now keeps its source, as the Linux and Windows image slots (imageSlot.src) and Android'scanvasSourcealready do, so an address cannot be reused while its key is cached.This was also the cause of the
TestCanvasImageCacheKeepsAWidePassflake: after the first pass's sources were collected, later sources reused their addresses and matched the evicted entries. The test is unchanged and no longer needs anything to keep its sources alive.The web backend has the same gap; it is left to #738.
Targets
core,base,ui,tsx, thensgotool)Screenshots
None. No visual change for an app whose buffers stay alive.
Verification
go test -count=50 -run TestCanvasImageCache ./internal/platform/appleon macOS arm64: passes 50 of 50; with the fix reverted, 13 of 50 runs fail with "a wide pass's evicted image kept its native image".go test ./internal/platform/applepasses.GOOS=ios GOARCH=arm64 go vet ./internal/platform/applepasses.Checklist