Skip to content
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

Fix updating root constraints #1387

Merged
merged 3 commits into from
Jun 7, 2024
Merged

Conversation

MatkovIvan
Copy link
Member

@MatkovIvan MatkovIvan commented Jun 6, 2024

Since owner.size doesn't really observed during composition setting scene size might not trigger invalidations

  • Manually run updateRootConstraints instead of marking size as state
  • Pick extra conditions from aosp/2598886

Fixes stretching reported in JetBrains/compose-multiplatform#4850

Testing

Run MultiLayerComposeSceneTest

Release Notes

Fixes - iOS

  • Fix missing invalidations during native view resize

@elijah-semyonov elijah-semyonov removed their request for review June 7, 2024 08:12
@elijah-semyonov
Copy link

elijah-semyonov commented Jun 7, 2024

LGTM, but I'd prefer other people to look at it as well. Can't completely assess possible side effects of this solution as opposed to manual invalidation call.

@MatkovIvan MatkovIvan merged commit e0fe94b into jb-main Jun 7, 2024
6 checks passed
@MatkovIvan MatkovIvan deleted the ivan.matkov/fix-root-constrains branch June 7, 2024 12:10
elijah-semyonov added a commit that referenced this pull request Jun 10, 2024
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](JetBrains/compose-multiplatform#4850)

Otherwise associated drawable pools are retained until next GC, which
can happen after inadequate amount of drawables with new sizes are
allocated

###
Before:
<img width="414" alt="Screenshot 2024-06-06 at 13 33 46"
src="https://github.com/JetBrains/compose-multiplatform-core/assets/4167681/81d74dfe-91c0-4362-ad71-93416dbe172f">
###
After:
<img width="574" alt="Screenshot 2024-06-07 at 10 04 18"
src="https://github.com/JetBrains/compose-multiplatform-core/assets/4167681/6574b297-1e81-48db-9aee-d31c2425267c">


## Testing

Resize the popup with `ComposeUIViewController` to different detents
inside Demo `IosBugs/PopupStretching`
Requires either patch:
```
Index: compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.uikit.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.uikit.kt b/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.uikit.kt
--- a/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.uikit.kt	(revision 39d436a)
+++ b/compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeSceneMediator.uikit.kt	(date 1717747754590)
@@ -558,6 +558,7 @@
                 asDpRect().toRect()
             }
         }
+        onComposeSceneInvalidate()
         scene.size = IntSize(
             width = boundsInPx.width.roundToInt(),
             height = boundsInPx.height.roundToInt()
```
Or #1387

## Release Notes

### iOS - Fixes
- Fixed a memory spike when continuously resizing the
`ComposeUIViewController` (such as when used in modal sheet presentation
context with different detents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants