Bug 233925 - Cocoa UI-side compositing compositor does not hold use count of layer contents before CA commits
Summary: Cocoa UI-side compositing compositor does not hold use count of layer content...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Compositing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-07 05:36 PST by Kimmo Kinnunen
Modified: 2022-01-13 19:08 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Kinnunen 2021-12-07 05:36:34 PST
Cocoa compositor does not hold use count of layer contents before CA commits

When IOSurface is put as the contents of a CALayer, CA will increment the use count. However, this only happens during CA transaction commit.

UI-side compositing, WP part will reuse backing stores that are not in use by CA. This is done by checking the use count.
However, this check is not entirely correct, as it can happen that backing store being reused has not entered the transaction commit in the UI process.
Comment 1 Kimmo Kinnunen 2021-12-07 05:36:47 PST
Something along the lines of:

UI-side compositing, WP part should:
1) increase the use count when iosurface is marked to belong to a ImageBuffer (during image buffer construction)
2) draw to the image buffer
3) convert the image buffer to a insurance by marking the image buffer as "not in use" (e.g. transfer the use-count to the holder of the iosurface reference)
2) send the iosurface to the UI process

UI-side compositing, UI part should:
1) convert the iosurface reference to iosurface, adopting the use count
2) put the iosurface to CALayer
3) commit the transaction
4) destroy all iosurfaces, releasing the adopted use count 

When recycling the spare image buffers to new display buffers, WP part should:
1) check if use count == 0, e.g. that the image buffer is not in use anymore
2) convert the image buffer to in-use image buffer (e.g. increment the use count)
Comment 2 Radar WebKit Bug Importer 2021-12-07 05:37:13 PST
<rdar://problem/86152460>