6

Hi I'm trying to update the AdapterList Composable item asynchronously. I put Image as one of the List Item. The image data is downloading from server using coroutine and update the value using state. When I fling the list items, got following error

    java.lang.IllegalStateException: Asking for measurement result of unmeasured layout modifier
        at androidx.ui.core.LayoutNodeWrapper.getMeasureResult(LayoutNodeWrapper.kt:58)
        at androidx.ui.core.LayoutNodeWrapper.getMeasuredSize(LayoutNodeWrapper.kt:48)
        at androidx.ui.core.Placeable.getWidth(Placeable.kt:40)
        at androidx.ui.core.LayoutNode.getWidth(ComponentNodes.kt:841)
        at androidx.ui.foundation.ListState.composeAndMeasureNextItem-BTEqjtU(AdapterList.kt:222)
        at androidx.ui.foundation.ListState.consumePendingScroll(AdapterList.kt:151)
        at androidx.ui.foundation.ListState.access$consumePendingScroll$3(Unknown Source:0)
        at androidx.ui.foundation.ListState$ListMeasureBlocks.measure(AdapterList.kt:277)
        at androidx.ui.core.InnerPlaceable.performMeasure(InnerPlaceable.kt:43)
        at androidx.ui.core.LayoutNodeWrapper.measure(LayoutNodeWrapper.kt:99)
        at androidx.ui.core.DelegatingLayoutNodeWrapper.performMeasure(DelegatingLayoutNodeWrapper.kt:79)
        at androidx.ui.core.LayerWrapper.performMeasure(LayerWrapper.kt:52)
        at androidx.ui.core.LayoutNodeWrapper.measure(LayoutNodeWrapper.kt:99)
        at androidx.ui.core.DelegatingLayoutNodeWrapper.performMeasure(DelegatingLayoutNodeWrapper.kt:79)
        at androidx.ui.core.LayoutNodeWrapper.measure(LayoutNodeWrapper.kt:99)
        at androidx.ui.core.DelegatingLayoutNodeWrapper.performMeasure(DelegatingLayoutNodeWrapper.kt:79)
        at androidx.ui.core.LayoutNodeWrapper.measure(LayoutNodeWrapper.kt:99)
        at androidx.ui.core.DelegatingLayoutNodeWrapper.performMeasure(DelegatingLayoutNodeWrapper.kt:79)
        at androidx.ui.core.LayoutNodeWrapper.measure(LayoutNodeWrapper.kt:99)
        at androidx.ui.core.LayoutNode$measure$2.invoke(ComponentNodes.kt:1177)
        at androidx.ui.core.LayoutNode$measure$2.invoke(Unknown Source:0)
        at androidx.ui.core.ModelObserver.observeReads(ModelObserver.kt:151)
        at androidx.ui.core.AndroidComposeView.observeMeasureModelReads(AndroidOwner.kt:487)
        at androidx.ui.core.LayoutNode.measure(ComponentNodes.kt:1176)

2 Answers 2

3

I've seen this a few times myself with both lists downloading images like you're describing and also lists without any async work being done, but I don't think it's caused by anything we're specifically doing. My impression is that it's just a bug with the current state of Compose.

That being said, AndroidComposeViewAccessibilityDelegateCompat is at least one class that handles this error and references an internal Issue Tracker ticket that's indicating it will be fixed in Android R, at least for that instance.

} catch (e: IllegalStateException) {
    // We may get "Asking for measurement result of unmeasured layout modifier" error.
    // TODO(b/153198816): check whether we still get this exception when R is in.
    info.setBoundsInScreen(android.graphics.Rect())
}

There's also an upcoming change in dev11 that updates AdapterList to dispose of compositions scrolled off screen and I'm curious to see how this affects things.

And if you're just curious about where the error is being thrown you can check out LayoutNodeWrapper._measureResult.

2
0

This issue is fixed in Compose version 0.1.0-dev14

You can update your compose dependencies to

 composeOptions {
    kotlinCompilerExtensionVersion '0.1.0-dev14'
    kotlinCompilerVersion '1.3.70-dev-withExperimentalGoogleExtensions-20200424'
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.