Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 59afaf76b51affaad6d3e5d28c243b9ea00da36b
https://github.com/WebKit/WebKit/commit/59afaf76b51affaad6d3e5d28c243b9ea00da36b
Author: Etienne Segonzac <[email protected]>
Date: 2026-03-07 (Sat, 07 Mar 2026)
Changed paths:
M
Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView+Analysis.swift
M
Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView+Generation.swift
M Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView+Surface.swift
M Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView.swift
Log Message:
-----------
[visionOS] Make WKSeparatedImageView compliant with Swift Strict Safety
https://bugs.webkit.org/show_bug.cgi?id=309357
<rdar://164555610>
Reviewed by Richard Robinson and Mike Wyrzykowski.
Move away from the single-pass hashing + encoding of the CGImage, which
used a lot of unsafe calls. Use a simpler 2 step process instead.
We make up for the potential performance impact by lazily generating the
encoded image data. Which means that on cache hits we never need to go
through the encoder (the most expensive part).
* Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView+Analysis.swift:
(WKSeparatedImageView.analyze):
Use the new lazy `ensureImageData()`.
* Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView+Generation.swift:
(WKSeparatedImageView.generate):
Use the new lazy `ensureImageData()`.
Add the unsafe keyword to the `generate()` call (known issue).
* Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView+Surface.swift:
(WKSeparatedImageView.didReceiveImage):
(WKSeparatedImageView.ensureImageData):
(WKSeparatedImageView.computeHash(_:)):
(WKSeparatedImageView.encode(_:)):
(WKSeparatedImageView.computeHash() async -> (Data:NSString:)): Deleted.
(StreamHasher.outputStream): Deleted.
(cgImageAsDataWithHash(_:NSString:)): Deleted.
Use the new 2-step hash, then encode for the CGImage.
This lets run return early without paying the encoding cost on cache
hits.
Both `computeHash` and `encode` are tagged as `@concurrent`.
* Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView.swift:
(WKSeparatedImageView.setSurface(_:)):
(WKObservingLayerDelegate.layerSeparatedDidChange):
(WKObservingLayerDelegate.layerWasCleared):
Remove an unsafe capture that's no longer needed.
Drive-by: remove the `@objc` on the Swift-only `WKObservingLayerDelegate`,
and the nonisolated that are not longer needed.
Canonical link: https://commits.webkit.org/308864@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications