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

TextField crashes after selecting the text and then deactivating the text field #1474

Closed
brolicious12 opened this issue Nov 26, 2021 · 7 comments
Assignees
Milestone

Comments

@brolicious12
Copy link

Run the program below, select the text and click the button to disable the text field
-> error

working with

id("org.jetbrains.kotlin.jvm") version ("1.5.31")
id("org.jetbrains.compose") version ("1.0.0-beta6-dev474")

windows 10
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Use active SlotWriter to determine anchor location instead). Please report to Google or use https://goo.gle/compose-feedback
	at androidx.compose.runtime.ComposerKt.composeRuntimeError(Composer.kt:3455)
	at androidx.compose.runtime.SlotTable.anchorIndex(SlotTable.kt:2700)
	at androidx.compose.runtime.Anchor.toIndexFor(SlotTable.kt:471)
	at androidx.compose.runtime.CompositionImpl.invalidate(Composition.kt:684)
	at androidx.compose.runtime.RecomposeScopeImpl.invalidate(RecomposeScopeImpl.kt:157)
	at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$onValueChangeWrapper$1.invoke(CoreTextField.kt:245)
	at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$onValueChangeWrapper$1.invoke(CoreTextField.kt:239)
	at androidx.compose.foundation.text.selection.TextFieldSelectionManager.deselect-_kEHs6E$foundation(TextFieldSelectionManager.kt:438)
	at androidx.compose.foundation.text.selection.TextFieldSelectionManager.deselect-_kEHs6E$foundation$default(TextFieldSelectionManager.kt:425)
	at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$focusModifier$1.invoke(CoreTextField.kt:291)
	at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$focusModifier$1.invoke(CoreTextField.kt:270)
	at androidx.compose.ui.focus.FocusChangedModifierKt$onFocusChanged$2$1.invoke(FocusChangedModifier.kt:47)
	at androidx.compose.ui.focus.FocusChangedModifierKt$onFocusChanged$2$1.invoke(FocusChangedModifier.kt:44)
	at androidx.compose.ui.focus.FocusEventModifierImpl.onFocusEvent(FocusEventModifier.kt:39)
	at androidx.compose.ui.node.ModifiedFocusEventNode.propagateFocusEvent(ModifiedFocusEventNode.kt:30)
	at androidx.compose.ui.node.ModifiedFocusNode.sendOnFocusEvent(ModifiedFocusNode.kt:70)
	at androidx.compose.ui.node.ModifiedFocusNode.setFocusState(ModifiedFocusNode.kt:55)
	at androidx.compose.ui.focus.FocusTransactionsKt.clearFocus(FocusTransactions.kt:146)
	at androidx.compose.ui.focus.FocusTransactionsKt.clearFocus(FocusTransactions.kt:156)
	at androidx.compose.ui.focus.FocusManagerImpl.clearFocus(FocusManager.kt:116)
	at androidx.compose.ui.node.ModifiedFocusNode.clearFocusIfFocused(ModifiedFocusNode.kt:94)
	at androidx.compose.ui.node.ModifiedFocusNode.detach(ModifiedFocusNode.kt:86)
	at androidx.compose.ui.node.LayoutNode.setModifier(LayoutNode.kt:741)
	at androidx.compose.ui.node.ComposeUiNode$Companion$SetModifier$1.invoke(ComposeUiNode.kt:41)
	at androidx.compose.ui.node.ComposeUiNode$Companion$SetModifier$1.invoke(ComposeUiNode.kt:41)
	at androidx.compose.runtime.ComposerImpl$apply$operation$1.invoke(Composer.kt:1427)
	at androidx.compose.runtime.ComposerImpl$apply$operation$1.invoke(Composer.kt:1425)
	at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:637)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:488)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:425)
	at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.kt:42)
	at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:71)
	at androidx.compose.ui.ComposeScene.render(ComposeScene.skiko.kt:343)
	at androidx.compose.ui.awt.ComposeLayer$1.onRender(ComposeLayer.desktop.kt:194)
	at org.jetbrains.skiko.SkiaLayer.update$skiko(SkiaLayer.jvm.kt:435)
	at org.jetbrains.skiko.redrawer.Direct3DRedrawer.update(Direct3DRedrawer.kt:56)
	at org.jetbrains.skiko.redrawer.Direct3DRedrawer.access$update(Direct3DRedrawer.kt:12)
	at org.jetbrains.skiko.redrawer.Direct3DRedrawer$frameDispatcher$1.invokeSuspend(Direct3DRedrawer.kt:30)
	at org.jetbrains.skiko.redrawer.Direct3DRedrawer$frameDispatcher$1.invoke(Direct3DRedrawer.kt)
	at org.jetbrains.skiko.redrawer.Direct3DRedrawer$frameDispatcher$1.invoke(Direct3DRedrawer.kt)
	at org.jetbrains.skiko.FrameDispatcher$job$1.invokeSuspend(FrameDispatcher.kt:33)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
	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)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: source index -150 out of bounds for int[5120]
	at java.base/java.lang.System.arraycopy(Native Method)
	at kotlin.collections.ArraysKt___ArraysJvmKt.copyInto(_ArraysJvm.kt:1316)
	at androidx.compose.runtime.SlotWriter.moveGroupGapTo(SlotTable.kt:1878)
	at androidx.compose.runtime.SlotWriter.close(SlotTable.kt:1096)
	at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:894)
	at androidx.compose.ui.ComposeScene.close(ComposeScene.skiko.kt:195)
	at androidx.compose.ui.awt.ComposeLayer.dispose(ComposeLayer.desktop.kt:266)
	at androidx.compose.ui.awt.ComposeWindowDelegate.dispose(ComposeWindowDelegate.desktop.kt:102)
	at androidx.compose.ui.awt.ComposeWindow.dispose(ComposeWindow.desktop.kt:105)
	at androidx.compose.ui.window.Window_desktopKt$Window$4.invoke(Window.desktop.kt:192)
	at androidx.compose.ui.window.Window_desktopKt$Window$4.invoke(Window.desktop.kt:192)
	at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2$invoke$$inlined$onDispose$1.dispose(Effects.kt:484)
	at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
	at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:793)
	at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:647)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:488)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:425)
	at androidx.compose.ui.window.YieldFrameClock.withFrameNanos(Application.desktop.kt:260)
	at androidx.compose.ui.window.YieldFrameClock$withFrameNanos$1.invokeSuspend(Application.desktop.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
	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)

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication {
	var text by remember { mutableStateOf("this is sparta") }
	var enabled by remember { mutableStateOf(true) }
	
	Column {
		Button(
			onClick = { enabled = !enabled },
			modifier = Modifier.fillMaxWidth()
		      ) {
			Text("click to enable/disable textfield")
		}
		
		TextField(
			value = text,
			onValueChange = { text = it },
			modifier = Modifier.fillMaxWidth(),
			enabled = enabled
		         )
	}
}
@igordmn
Copy link
Collaborator

igordmn commented Nov 26, 2021

Reproduces also in Jetpack Compose 1.0.2 on Android

@igordmn igordmn added p:high High priority and removed p:critical Critical priority labels Nov 26, 2021
@igordmn
Copy link
Collaborator

igordmn commented Dec 3, 2021

@theapache64
Copy link
Contributor

@igordmn Any workaround for this issue? Still replicable in id("org.jetbrains.compose") version "1.1.0-alpha03"

@akurasov
Copy link
Contributor

akurasov commented Feb 7, 2022

@theapache64 could you check if it is reproducible on the latest Jetpack Compose (on Android), since Google marked this bug as fixed?

Upd: no need. It haven't got to our repo so far. We will get it.

@theapache64
Copy link
Contributor

theapache64 commented Feb 7, 2022 via email

@akurasov
Copy link
Contributor

akurasov commented Feb 9, 2022

This fix is not available in Jetpack Compose 1.1 build at the moment. If you needed it, you could comment to the google ticket or create a new one there.

@akurasov
Copy link
Contributor

Fixed in 1.1.0-alpha04

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

No branches or pull requests

5 participants