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

First screen is recomposed twice on iOS #3778

Closed
pjBooms opened this issue Oct 5, 2023 · 1 comment · Fixed by JetBrains/compose-multiplatform-core#861
Closed

First screen is recomposed twice on iOS #3778

pjBooms opened this issue Oct 5, 2023 · 1 comment · Fixed by JetBrains/compose-multiplatform-core#861
Assignees
Labels
bug Something isn't working ios p:high High priority reproduced

Comments

@pjBooms
Copy link
Collaborator

pjBooms commented Oct 5, 2023

The following code snippet:

@Composable
fun App() {
    val value = remember(LocalDensity.current) {
        (1..100).random()
    }
    println("Density: ${LocalDensity.current}")
    println("value is $value")
}

results in the following output:

Density: DensityImpl(density=1.0, fontScale=1.0)
value is 15
Density: DensityImpl(density=3.0, fontScale=1.0)
value is 34

on iOS.

That may have side effects like in the #3766 issue.

We should initialize density to correct value before first composition to eliminate this.

@pjBooms pjBooms added bug Something isn't working submitted labels Oct 5, 2023
@pjBooms pjBooms added ios and removed submitted labels Oct 5, 2023
@elijah-semyonov
Copy link
Contributor

elijah-semyonov commented Oct 6, 2023

@dima-avdeev-jb
We need to defer the first recomposition until didMoveToWindow was called with non-nil window. That's when a correct density scale is available.

@pjBooms pjBooms assigned eymar and unassigned dima-avdeev-jb Oct 6, 2023
@pjBooms pjBooms added the p:high High priority label Oct 6, 2023
eymar added a commit to JetBrains/compose-multiplatform-core that referenced this issue Oct 10, 2023
Fixes: JetBrains/compose-multiplatform#3778

Implemented according to what @elijah-semyonov suggested:

> We need to defer the first recomposition until `didMoveToWindow` was
called with non-nil window. That's when a correct density scale is
available.

---------

Co-authored-by: dima.avdeev <dima.avdeev@jetbrains.com>
mazunin-v-jb pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 7, 2023
Fixes: JetBrains/compose-multiplatform#3778

Implemented according to what @elijah-semyonov suggested:

> We need to defer the first recomposition until `didMoveToWindow` was
called with non-nil window. That's when a correct density scale is
available.

---------

Co-authored-by: dima.avdeev <dima.avdeev@jetbrains.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios p:high High priority reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants