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

Webview in JavaFx demo is blank #69

Closed
bjonnh opened this issue Mar 17, 2021 · 24 comments
Closed

Webview in JavaFx demo is blank #69

bjonnh opened this issue Mar 17, 2021 · 24 comments
Assignees
Labels
bug Something isn't working fixed in dev Fixed in development version

Comments

@bjonnh
Copy link

bjonnh commented Mar 17, 2021

Curiously the webview is blank it is the same in my application. If I connect to http://localhost:7777/Static or /Dynamic with a webbrowser it works perfectly and it even react to the scale slider in the Dynamic demo.

If I load a random webpage with plotly on it inside WebView (https://chart-studio.plotly.com/create/?fid=plotly2_demo:4#/) , it works, so WebView is working properly and javascript in it as well.

Using JavaFX 15 on Linux (Wayland).

I looked at the onerror/onalert, but nothing showed up.

I tested with your main branch only.

The dev branch fails with

> Task :fx-demo:run FAILED
Error: Could not find or load main class kscience.plotly.fx.PlotlyFXAppKt
Caused by: java.lang.ClassNotFoundException: kscience.plotly.fx.PlotlyFXAppKt
```
@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

In the dev branch, I updated the fx-demo/build.gradle.kts

with

application {
    mainClassName = "space.kscience.plotly.fx.PlotlyFXAppKt"
}

as you changed the names, and changed the javafx version to 15, but it behaves exactly the same.

@altavir
Copy link
Member

altavir commented Mar 17, 2021

I just tried it from the latest dev build (and thank you, I had to fix entry points): e3f8978. It is working as expected. Could you try the dev build (clone and gradlew :fx-demo:run). Maybe JS bundle deploy failed in intermediate versions. I tshould work fin in the new release.

I am also thinking about moving to CEF implementation and Compose-Desktop. But I do not have time for it right now.

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

I tried the dev build it does exactly the same thing. I think all the back end works properly, it is really something in webview that is not working. What Java/JavaFX version and platform are you using?

I'm surprised webview works with all the websites I tested but fails with this. And other browsers have absolutely no issue displaying it.

I may try compose-desktop but that would mean porting all of my application from JavaFX to that (not that it is big)…

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

Interestingly it works with Java11…
The 11 and 15 are from the same source (ArchLinux packages).

@altavir
Copy link
Member

altavir commented Mar 17, 2021

I've reproduced the problem on liberica-15. I'll look into it.

@altavir
Copy link
Member

altavir commented Mar 17, 2021

Interesting. It seems to be a Ktor bug.

17:24:26.967 [DefaultDispatcher-worker-2 @request-handler#28] ERROR ktor.application - Unhandled: GET - /
java.lang.NullPointerException: jarEntry must not be null
	at io.ktor.http.content.JarFileContent.<init>(JarFileContent.kt:41)
	at io.ktor.http.content.StaticContentResolutionKt.resourceClasspathResource(StaticContentResolution.kt:62)
	at io.ktor.http.content.StaticContentResolutionKt.resolveResource(StaticContentResolution.kt:38)
	at io.ktor.http.content.StaticContentResolutionKt.resolveResource$default(StaticContentResolution.kt:24)
	at io.ktor.http.content.StaticContentKt$resources$1.invokeSuspend(StaticContent.kt:230)
	at io.ktor.http.content.StaticContentKt$resources$1.invoke(StaticContent.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:246)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
	at io.ktor.routing.Routing.executeResult(Routing.kt:155)
	at io.ktor.routing.Routing.interceptor(Routing.kt:39)
	at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:107)
	at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:82)
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:60)
	at io.ktor.util.pipeline.DebugPipelineContext.execute(DebugPipelineContext.kt:66)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invokeSuspend(DefaultEnginePipeline.kt:124)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:82)
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:60)
	at io.ktor.util.pipeline.DebugPipelineContext.execute(DebugPipelineContext.kt:66)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
	at io.ktor.server.cio.CIOApplicationEngine$handleRequest$2.invokeSuspend(CIOApplicationEngine.kt:189)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

I do not see that error, maybe there is no logging by default?

@altavir
Copy link
Member

altavir commented Mar 17, 2021

Yes, I switched to different logging in DataForge and now logback is not provided by default. One needs to add implementation("ch.qos.logback:logback-classic:1.2.3") to dependencies for logs to work. I fixed the problem with ktor, but I still can't see the picture on JDK 15.

@altavir
Copy link
Member

altavir commented Mar 17, 2021

@bjonnh I've localized the problem. It is the crappy FX-browser again. The problem is that plotly JS is rather large and it takes some time to load it. And FX browser does not process the loading event properly for some reason. I will try to find a workaround for that.

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

Ok let me have a look at how it is handled, I may be able to help with that.

@altavir
Copy link
Member

altavir commented Mar 17, 2021

I've just pushed the commit with all logging attached. Toggling back-forward button on the plotly windows makes it display the plot properly, but in general load worker is just stuck on RUNNING

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

(If you did read what I wrote before deleting, that's because I ran directly from IntelliJ not the gradle task)

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

I see where the problem is, you really need to have a function that waits on Plotly to be loaded because order of loading/running scripts is never guaranteed.

@altavir
Copy link
Member

altavir commented Mar 17, 2021

I see. It is fixed in the more advanced VisionForge implementation. Probably I will just back-port it to Plotly.

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

But that's pretty clearly unexpected from JavaFX Webview. It should probably behave like other browsers. You can try sending a bug-report to the JavaFX team, but I was never successful at doing that.

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

There is something really weird, if I take a page served by the ktor server, it fails. If I take the html put it on a webserver and load it there, it works see:
https://www.bjonnh.net/share/test_static.html

@altavir
Copy link
Member

altavir commented Mar 17, 2021

Yes, I had some weird bugs with FX-browser. Sadly it lives in its own world sometimes. I will back-port the solution from VisionForge. It uses Kotlin JS bundling thus solving the loading order problem. As soon as VisionForge is more stable, I will just deprecate server support in plotly.kt. VisionForge is much more powerful anyway (and it already works well with plotly.kt).

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

Once I tell it to not load PlotlyConnect, it works fine.

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

Do you have a demo on how to have simple plots in VisionForge with JavaFX?

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

This makes little sense to me, plotlyConnect.js is just defining functions…

@bjonnh
Copy link
Author

bjonnh commented Mar 17, 2021

From what I see when logging with Ktor, it doesn't even try to load the JS…

@altavir
Copy link
Member

altavir commented Mar 17, 2021

Indeed. For some reason, it randomly loads the first scripts and forgets to load the other one or does not load anything at all. When I searched for a fix, people proposed to store the webEngine in a static variable because it gets GCed. But I tried that and it does not help. I will do both Plotly backport and the VisionForge demo in a few days.

@altavir
Copy link
Member

altavir commented Mar 18, 2021

@bjonnh I've implemented the back-port, but it did not help. The problem is not the loading order, but just a bugged loader after all. Surprisingly, downgrading JavaFX version to 11 helped. So now it works on dev.

@altavir
Copy link
Member

altavir commented Mar 24, 2021

Considered it fixed for now. FX version 11 seems to be working fine.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in dev Fixed in development version
Projects
None yet
Development

No branches or pull requests

2 participants