Improved drawable management#2732
Merged
Andrei Salavei (ASalavei) merged 16 commits intoFeb 17, 2026
Merged
Conversation
390e5ea to
f85c4f6
Compare
This reverts commit 7762ba5.
Vendula Švastalová (svastven)
left a comment
There was a problem hiding this comment.
Few small comments, otherwise LGTM 👏🏻
Vendula Švastalová (svastven)
approved these changes
Feb 12, 2026
ApoloApps
reviewed
Feb 13, 2026
# Conflicts: # compose/ui/ui/src/iosMain/kotlin/androidx/compose/ui/window/MetalRedrawer.ios.kt
Merged
Copilot started reviewing on behalf of
Ivan Matkov (MatkovIvan)
February 16, 2026 22:20
View session
There was a problem hiding this comment.
Pull request overview
This PR introduces a new parallel rendering implementation for iOS using a custom CMPMetalLayer that manages a pool of IOSurface-backed Metal drawables. The implementation aims to fix crashes and improve performance when parallel rendering is enabled by giving explicit control over drawable lifecycle and presentation timing.
Changes:
- Enables
parallelRenderingby default (changed fromfalsetotrue) - Implements
CMPMetalLayerandCMPDrawablein Objective-C to manage a pool of up to 3 Metal drawables with IOSurface backing - Adds
SurfaceMetalViewandSurfaceMetalRedraweras the new default implementation when parallel rendering is enabled - Refactors existing implementations into
LegacyMetalViewandLegacyMetalRedraweras fallback when parallel rendering is disabled - Converts
MetalViewandMetalRedrawerinto sealed interfaces with factory functions to hide implementation details
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ComposeContainerConfiguration.ios.kt | Changes parallelRendering default from false to true and updates documentation |
| MetalView.ios.kt | Converts MetalView class to MetalViewHolder interface and factory function; renames existing implementation to LegacyMetalView |
| MetalRedrawer.ios.kt | Converts MetalRedrawer class to sealed interface; renames existing implementation to LegacyMetalRedrawer; changes command buffer handler from addCompletedHandler to addScheduledHandler |
| SurfaceMetalView.ios.kt | New implementation using CMPMetalLayer for parallel rendering |
| SurfaceMetalRedrawer.ios.kt | New redrawer implementation with separate rendering queue and drawable pool management |
| CMPMetalLayer.h/.m | New Objective-C class managing a pool of 3 IOSurface-backed Metal drawables with explicit lifecycle control |
| CMPDrawable.h/.m | New Objective-C class representing an IOSurface-backed Metal drawable |
| CMPMetalLayerTests.swift | Comprehensive test suite for CMPMetalLayer with 423 lines covering various scenarios |
| UIKitInteropTransaction.ios.kt | Adds performTransaction() helper method to simplify action execution |
| ComposeContainerView.ios.kt | Updates to use MetalViewHolder interface instead of concrete MetalView class |
| ComposeLayersViewController.ios.kt | Updates to use MetalViewHolder interface |
| UIKitComposeSceneLayer.ios.kt | Accesses view property through MetalViewHolder interface |
| MetalRedrawerTest.kt | Updates test to use CMPMetalLayer and SurfaceMetalRedrawer |
| ComposeSceneMediatorTest.kt | Updates test to use CMPMetalLayer and SurfaceMetalRedrawer |
| main.ios.kt | Removes explicit parallelRendering = true configuration as it's now the default |
| CMPUIKitUtils.h | Adds imports for new CMPDrawable and CMPMetalLayer headers |
| project.pbxproj | Adds new source files and test files to Xcode project |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ivan Matkov (MatkovIvan)
approved these changes
Feb 16, 2026
Vladimir Mazunin (mazunin-v-jb)
approved these changes
Feb 17, 2026
Vendula Švastalová (svastven)
approved these changes
Feb 17, 2026
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.
parallelRenderingby default.CMPMetalLayerclass, which can manage a pool of self-allocated metal textures and use an IOSurface for presentation.parallelRenderingflag is set totrue.LegacyMetalViewandLegacyRedraweras a backup option when the theparallelRenderingflag is set tofalse.MetalViewandMetalRedrawerwhere converted into the interfaces to hide implementation details of the corresponding classes.Fixes https://youtrack.jetbrains.com/issue/CMP-9559/Fix-waiting-for-next-drawable-by-the-main-thread
Fixes https://youtrack.jetbrains.com/issue/CMP-7598/Skia-crash-on-iOS-GrResourceCachenotifyARefCntReachedZero
Release Notes
Migration Notes - iOS
parallelRenderingflag now enabled by default.Fixes - iOS
parallelRenderingis enabled.