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

java.lang.IllegalStateException: Size is unspecified using Painter class #197

Open
N7ghtm4r3 opened this issue Nov 24, 2024 · 0 comments
Open

Comments

@N7ghtm4r3
Copy link

Hi, I'm implementing a custom component uses your library to get the dominant color from an image and I'm facing with an issue when I use it with the Painteroption.
My code is the following:

@Composable
@NonRestartableComposable
fun CustomComponent(
    backgroundPainter: Painter
) {
    val loader = rememberPainterLoader()
    val dominantColorState = rememberDominantColorState(
        loader = loader
    )
    LaunchedEffect(backgroundPainter) {
        dominantColorState.updateFrom(backgroundPainter)
    }
    when (dominantColorState.result) {
        is PaletteResult.Error -> {
            val error = (dominantColorState.result as PaletteResult.Error).cause
            throw IllegalArgumentException(error) // the same result in all the tests
        }
        is PaletteResult.Loading -> {
            CircularProgressIndicator()
            Text("Loading...")
        }
        is PaletteResult.Success -> {
            //custom component
        }
        null -> {}
    }
}

The exception stacktrace:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: java.lang.IllegalStateException: Size is unspecified
	at com.tecknobit.equinoxcompose.components.CustomComponent.CustomComponent-V11v3y8(CustomComponent.kt:107)
	at com.custom.A.AScreen$ArrangeScreenContent$1$1.invoke(AScreen.kt:71)
	at com.custom.screens.A.AScreen$ArrangeScreenContent$1$1.invoke(AScreen.kt:49)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jb.kt:108)
	at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jb.kt:108)
	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2825)
	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3116)
	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3607)
	at androidx.compose.runtime.ComposerImpl.recompose$runtime(Composer.kt:3552)
	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1206)
	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:132)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:616)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:585)
	at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.kt:42)
	at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:76)
	at androidx.compose.ui.scene.BaseComposeScene.render(BaseComposeScene.skiko.kt:168)
	at androidx.compose.ui.scene.ComposeSceneMediator$onRender$1$1.invoke(ComposeSceneMediator.desktop.kt:574)
	at androidx.compose.ui.scene.ComposeSceneMediator$onRender$1$1.invoke(ComposeSceneMediator.desktop.kt:572)
	at androidx.compose.ui.viewinterop.SwingInteropContainer.postponingExecutingScheduledUpdates(SwingInteropContainer.desktop.kt:229)
	at androidx.compose.ui.scene.ComposeSceneMediator.onRender(ComposeSceneMediator.desktop.kt:572)
	at org.jetbrains.skiko.SkiaLayer.update$skiko(SkiaLayer.awt.kt:533)
	at org.jetbrains.skiko.redrawer.AWTRedrawer.update(AWTRedrawer.kt:54)
	at org.jetbrains.skiko.redrawer.Direct3DRedrawer.redrawImmediately(Direct3DRedrawer.kt:74)
	at org.jetbrains.skiko.SkiaLayer.tryRedrawImmediately(SkiaLayer.awt.kt:373)
	at org.jetbrains.skiko.SkiaLayer.setBounds(SkiaLayer.awt.kt:360)
	at java.desktop/java.awt.Component.resize(Component.java:2254)
	at java.desktop/java.awt.Component.setSize(Component.java:2239)
	at androidx.compose.ui.scene.ComposeContainer.setBounds(ComposeContainer.desktop.kt:292)
	at androidx.compose.ui.awt.ComposeWindowPanel.setBounds(ComposeWindowPanel.desktop.kt:109)
	at java.desktop/java.awt.BorderLayout.layoutContainer(BorderLayout.java:843)
	at java.desktop/java.awt.Container.layout(Container.java:1541)
	at java.desktop/java.awt.Container.doLayout(Container.java:1530)
	at java.desktop/java.awt.Container.validateTree(Container.java:1725)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validate(Container.java:1660)
	at java.desktop/javax.swing.RepaintManager$3.run(RepaintManager.java:757)
	at java.desktop/javax.swing.RepaintManager$3.run(RepaintManager.java:755)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:754)
	at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1896)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.scene.ComposeContainer$DesktopCoroutineExceptionHandler@61ff3172, androidx.compose.runtime.BroadcastFrameClock@5315e57d, StandaloneCoroutine{Cancelling}@ae33e6e, FlushCoroutineDispatcher@408e09db]

This occurred in the desktop target, but also in the android one is the same.
From the stacktrace seems that is not thrown from your library, but if you can help me I really appreciate it, I'm not used to use the painters directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant