forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 60
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
iOS ComposeWindow memory leak fix #728
Merged
Merged
Conversation
This file contains 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
MatkovIvan
reviewed
Aug 3, 2023
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/window/ComposeWindow.uikit.kt
Show resolved
Hide resolved
dima-avdeev-jb
approved these changes
Aug 5, 2023
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/window/ComposeWindow.uikit.kt
Show resolved
Hide resolved
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/interop/LocalUIViewController.uikit.kt
Show resolved
Hide resolved
pjBooms
approved these changes
Aug 8, 2023
elijah-semyonov
added a commit
that referenced
this pull request
Aug 11, 2023
This reverts commit 1071df2.
igordmn
pushed a commit
that referenced
this pull request
Aug 11, 2023
## Proposed Changes Revert [memory leak fix PR](#728) Implement eager dispose on `viewDidDisappear`, reconstruct scene on `viewWillAppear` ## Testing Test: same as reverted PR ## API Changes `ComposeUIViewController` now disposes the composition on `viewDidDisappear` and reconstructs it on `viewWillAppear`. Clients should keep the important state outside of the composition and composition should subscribe to it: ``` class MyScreenState { var title by mutableStateOf("Title") private set } val state = MyScreenState() val viewController = ComposeUIViewController { Text(state.title) } ```
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.
Proposed Changes
Imply ownership semantics in ComposeWindow.ios.kt and wrap child->parent references into WeakReference.
Replace all places where
this
is explicitly captured by accessingComposeWindow
dynamic properties with explicitweakThis.get()?._property_name_
, capture newly created references to properties with non-value-semantics (such asMutableState
) directly in the scope where lambda is created to avoid implicitthis
capture and introducing nullable types for CompositionLocalTesting
Test: automatic test TBD.
Manual testing: launch project from Xcode, tap "Native modal with navigation", "Present popup", push several new
ComposeWindow
s tapping "Push" button, dismiss the modal using swipe-down interaction. Repeat multiple times.Open memory graph debug, ensure that ComposeWindow count is less than amount that was spawned previously.
Issues Fixed
Fixes: leaking ComposeWindow.
Depends on
JetBrains/skiko#771
## API ChangeReverted in #747LocalUIViewController
type changed fromProvidableCompositionLocal<UIViewController>
toProvidableCompositionLocal<WeakReference<LocalUIViewController>>