UI/Qt+LibCore: Lock IOSurface for safe CPU reads on macOS#9257
Open
christianfrey wants to merge 1 commit intoLadybirdBrowser:masterfrom
Open
UI/Qt+LibCore: Lock IOSurface for safe CPU reads on macOS#9257christianfrey wants to merge 1 commit intoLadybirdBrowser:masterfrom
christianfrey wants to merge 1 commit intoLadybirdBrowser:masterfrom
Conversation
On macOS, SharedImageBuffer bitmaps are backed by IOSurface memory that may be written by the GPU. Qt reads this memory from the CPU side when creating a QImage and rendering it with QPainter. On Intel Macs, reading IOSurfaceGetBaseAddress() without first taking a read lock results in blank pages in the Qt UI. Add read-only IOSurface lock helpers and use them around the Qt rendering path to ensure proper synchronization between GPU writes and CPU reads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Intel Macs, the IOSurface backing the Qt QImage may be updated by the GPU, but CPU access is not guaranteed to be coherent without explicit synchronization. This results in blank pages in the Qt UI.
This change adds lock_read_only() / unlock_read_only() around the Qt rendering path to ensure proper synchronization when reading from the IOSurface.
Apple Silicon is unaffected due to unified memory, but the locking is kept for correctness.