When creating a dead-simple WebView wrapper with Jetpack Compose, the app crashes the second I enter any text. Is this a bug, or am I doing something stupid? The relevant code:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
WebViewC()
}
}
}
@Composable
fun WebViewC() {
return AndroidView(viewBlock = { context ->
WebView(context).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
return false
}
}
loadUrl("https://google.com")
}
})
}
The crash:
E/MessageQueue-JNI: java.lang.IllegalStateException: KeyEvent can't be processed because this key input node is not active.
at androidx.compose.ui.input.key.KeyInputModifier.processKeyInput(KeyInputModifier.kt:62)
at androidx.compose.ui.platform.AndroidComposeView.sendKeyEvent(AndroidComposeView.kt:173)
at androidx.compose.ui.platform.AndroidComposeView.dispatchKeyEvent(AndroidComposeView.kt:177)