Skip to content

[BUG] WebView throwing error on configuration #344

Description

@StefanOltmann

Hi,

I encountered this Exception while trying to set properties to the WebView:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = AWT-EventQueue-0
	at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:294)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:481)
	at javafx.web/javafx.scene.web.WebEngine.checkThread(WebEngine.java:1220)
	at javafx.web/javafx.scene.web.WebEngine$1.invalidated(WebEngine.java:486)
	at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
	at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
	at javafx.web/javafx.scene.web.WebEngine.setJavaScriptEnabled(WebEngine.java:475)
	at com.mohamedrejeb.calf.ui.web.WebView_desktopKt.applySettings(WebView.desktop.kt:173)

We use the WebView like this in commonMain code:

val webViewState = rememberWebViewState(url)

LaunchedEffect(Unit) {

    webViewState.settings.javaScriptEnabled = true
    webViewState.settings.androidSettings.supportZoom = true
}

WebView(
    state = webViewState,
    modifier = Modifier.fillMaxSize()
)

What is the correct way to configure the WebView?

I assume that Platform.runLater() needs to be used, but I can't to that from commonMain.

What can I do to avoid this issue?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions