-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide Metal drawables from Kotlin runtime #1390
Conversation
import platform.UIKit.UISheetPresentationControllerDetent | ||
import platform.UIKit.sheetPresentationController | ||
|
||
//val bottomSheetUIViewController = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, removed
|
||
- (instancetype)initWithMetalLayer:(CAMetalLayer *)metalLayer; | ||
|
||
- (void * CMP_OWNED)nextDrawable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking about slightly more generic solution.
What do you think about creating analog of "Manual Reference Counter" that can wrap various classes and hide them from Kotlin GC?
Or maybe even play a bit with NSProxy to provide sufficient interface for Kotlin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to model this approach in my head, but didn't succeed. Do you have proof-of-concept available?
@@ -0,0 +1,29 @@ | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check copyright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPMetalDrawablesHandler.h
Show resolved
Hide resolved
// scheduleDrawablePresentation consumes metalDrawable | ||
// don't use metalDrawable after this call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just nullify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a smart cast val
, doing so will require to put force-unwraps everywhere
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/window/MetalRedrawer.uikit.kt
Outdated
Show resolved
Hide resolved
Do you reckon this is related? JetBrains/compose-multiplatform#4852 |
Yes, sorry, your comment notification slipped from my attention. I am glad it has fixed your problem too. |
Explicitly manage lifetime of metal drawables by hiding them from Kotlin runtime.
Fixes a memory spike when quickly resizing metal layer as in a scenario reported in the issue
Otherwise associated drawable pools are retained until next GC, which can happen after inadequate amount of drawables with new sizes are allocated
Before:
After:
Testing
Resize the popup with
ComposeUIViewController
to different detents inside DemoIosBugs/PopupStretching
Requires either patch:
Or #1387
Release Notes
Fixes - iOS
ComposeUIViewController
(such as when used in modal sheet presentation context with different detents)