KhubaibKhan4 / MediaPlayer-KMP

MediaPlayer-KMP is a Kotlin Multiplatform (KMP) library that allows you to display and play YouTube videos across Android, iOS, Web, and Desktop platforms using JetBrains Compose Multiplatform. It provides a unified API for video playback that seamlessly integrates into Kotlin's multiplatform ecosystem.
GNU General Public License v2.0
110 stars 7 forks source link

Desktop (Win) app crashing on v1.1.1 #35

Open adnanjelic opened 1 month ago

adnanjelic commented 1 month ago

It seems that the last update (v.1.1.1) broke the desktop version (I am testing on Windows 10). The v1.0.9 works fine.

The app crashes when initializing the player with:

Sep 21, 2024 7:20:39 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @42e5d77f'
Graphics Device initialization failed for :  d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
    at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:268)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.embed.swing.JFXPanel.lambda$initFx$1(JFXPanel.java:225)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    ... 1 more
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: No toolkit found
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:280)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.embed.swing.JFXPanel.lambda$initFx$1(JFXPanel.java:225)
    at java.base/java.lang.Thread.run(Thread.java:840)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.scene.ComposeContainer$DesktopCoroutineExceptionHandler@7f405f2f, androidx.compose.runtime.BroadcastFrameClock@6ca5d249, StandaloneCoroutine{Cancelling}@11b5ac12, FlushCoroutineDispatcher@66bcedab]

From my initial investigation, it seems JavaFX is not bundled with the JDK after Java 11. Can you bundle it with the lib so it is not required for the clients to have JavaFX installed, please? More info: https://stackoverflow.com/a/67854230

BTW: Thanks for the lib, looks really promising 🙏

KhubaibKhan4 commented 1 month ago

Thank you @adnanjelic. Let me check it out and I will update it soon. If you have any features recommendations, please let me know.

KhubaibKhan4 commented 1 month ago

@adnanjelic Just fixed the issue almost all the issues on this Repository. Just updating the latest version and publishing it to Maven Central. If you've any suggestions, Please let me know.

adnanjelic commented 1 month ago

Hi @KhubaibKhan4, thanks for the quick update, but unfortunately it is still crashing on the Desktopwith the same error.

adnanjelic commented 1 month ago

If it is of any help, desktop was working fine with 1.0.9 version.

KhubaibKhan4 commented 1 month ago

@adnanjelic I didn't include anything there, just added the full screen compatibility. Today, I will update and fix this issue tonight.

KhubaibKhan4 commented 1 month ago
Screenshot 2024-09-25 at 9 36 32 PM

Kindly Checkout this screenshot. Everything is working fine on my PC and my Mac as Well. Checkout the latest version. I'm also using the same version on my YouTube Clone KMP as well.

Latest Version: 1.1.4

adnanjelic commented 1 month ago

@KhubaibKhan4 you have shown a pic of the YoutTube player. The one I am mentioning is the classic video player running on Windows.

It was working on 1.0.9 image

But after that, it started crashing with the log I provided earlier.

With the latest 1.1.4 version, it still crashes with the same error, but now additionally shows this error dialog before killing the app: image

KhubaibKhan4 commented 1 month ago

Now, I understand the issue. Let me check it and fix it.

KhubaibKhan4 commented 1 month ago

@adnanjelic This issue has been fixed. Please give me your feedback on the latest version. Thank you.

adnanjelic commented 1 month ago

@KhubaibKhan4 I just tested it on 1.1.5 and the issue is still present:

Sep 28, 2024 12:04:15 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @7d63642a'
Graphics Device initialization failed for :  d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
    at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:268)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.embed.swing.JFXPanel.lambda$initFx$1(JFXPanel.java:225)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    ... 1 more
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: No toolkit found
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:280)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.embed.swing.JFXPanel.lambda$initFx$1(JFXPanel.java:225)
    at java.base/java.lang.Thread.run(Thread.java:840)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.scene.ComposeContainer$DesktopCoroutineExceptionHandler@adb96aa, androidx.compose.runtime.BroadcastFrameClock@67a2114a, StandaloneCoroutine{Cancelling}@780da845, FlushCoroutineDispatcher@4bd572da]

Looks like this issue: https://github.com/javafxports/openjdk-jfx/issues/237

KhubaibKhan4 commented 1 month ago
Screenshot 2024-09-29 at 9 47 47 PM

Checkout here, It's working fine. You might have some other issues. Please verify your system or try it on other system.

adnanjelic commented 1 month ago

Hi, yes, it is working on your mac because you probably have the JavaFX installed. I am testing on Windows and I do not have JavaFX installed.

So yes, the problem is in my system, it does not have JavaFX installed, it is what I have pointed out at the beginning. That is why I asked if you can bundle JavaFx together with the lib, so the end users do not have to download and install it.

I can probably fix this issue on my PC by installing JavaFx, but we cannot ask all the app users to download and install JavaFx so the app can work.

So I just want to ask again, can you please bundle the JavaFx with the lib so we do not have to ask users to install it each time?

KhubaibKhan4 commented 1 month ago

Hi @adnanjelic , Unfortunately I never install javafx on my Mac. I do have PC and it's also working fine there as well. I'll provide you the screenshot of my PC as well. The issue isn't with library, it might be any other issue, The issue you're facing is all about the exception that I'm throwing away. Please Provide me your repository link if it is available as public.

adnanjelic commented 1 month ago

Is there a reason why it worked on 1.0.9 but stopped working afterwards? I can still run the player with the 1.0.9 version

KhubaibKhan4 commented 1 month ago

@adnanjelic Issue is fixed. Please checkout the latest version. Thank you

adnanjelic commented 1 month ago

@KhubaibKhan4 Thanks for the support, but it still crashes on the 1.1.7 and still works on 1.0.9. Thanks for your support.

I have created a sample repo for you to check it out: https://github.com/adnanjelic/video-player-test

It is a simple app built with the compose MP template and only added your library.

The same crash occurs on Windows and it is happening because I do not have JavaFx bundled in the system (as many Win users I assume). Can you please bundle the JavaFx lib with your lib so we do not need the users to have it preinstalled?

KhubaibKhan4 commented 1 month ago

@adnanjelic That might be another issue because I replaced the 1.0.9 version code implementation on the latest version. Please let me know, So we can fix it. Thank you

adnanjelic commented 1 month ago

Hi @KhubaibKhan4 , I have tested this on my laptop, and it is the same issue. If the system does not have the JavaFX installed it will crash.

Probably if I install it to the system it would probably work, but that is not what I wanted, to require the users to have it preinstalled.

So I did add the JavaFX dependencies through the build.gradle and then the win desktop player plays for the first play, but unfortunately for the second and every subsequent it does not play and I can see this log:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "com.sun.javafx.tk.quantum.SceneState.update()" because "this.sceneState" is null

It seems an open bug: https://bugs.openjdk.org/browse/JDK-8334593

So, I am switching to another lib for now. But thanks for creating this and the support you are providing to it, keep up the good work 👍

KhubaibKhan4 commented 1 month ago

Thank you @adnanjelic . Can you provide me your jdk version?

adnanjelic commented 1 month ago

Sure, @KhubaibKhan4 it is 17.0.11

KhubaibKhan4 commented 1 month ago

Can you checkout the latest version Please and let me know.

adnanjelic commented 1 month ago

Hi @KhubaibKhan4, I have tested it now with Java 21 and FX 22 but it still throws the same error (you can play the video only one time)

com.sun.javafx.application.PlatformImpl startup WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @3911526f' Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "com.sun.javafx.tk.quantum.SceneState.update()" because "this.sceneState" is null at com.sun.javafx.tk.quantum.GlassScene.updateSceneState(GlassScene.java:285) at com.sun.javafx.tk.quantum.EmbeddedScene.lambda$setPixelScaleFactors$1(EmbeddedScene.java:159) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithRenderLock(QuantumToolkit.java:448) at com.sun.javafx.tk.quantum.EmbeddedScene.lambda$setPixelScaleFactors$2(EmbeddedScene.java:158) at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) at java.base/java.lang.Thread.run(Thread.java:1583) Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "com.sun.javafx.tk.quantum.SceneState.update()" because "this.sceneState" is null at com.sun.javafx.tk.quantum.GlassScene.updateSceneState(GlassScene.java:285) at com.sun.javafx.tk.quantum.EmbeddedScene.lambda$setPixelScaleFactors$1(EmbeddedScene.java:159) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithRenderLock(QuantumToolkit.java:448) at com.sun.javafx.tk.quantum.EmbeddedScene.lambda$setPixelScaleFactors$2(EmbeddedScene.java:158) at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) at java.base/java.lang.Thread.run(Thread.java:1583)

Following the JavaFX bug from my previous message (the problem occurs on versions >= 21), I also tried to use used java 20 and javaFx 20 as a dependency, but since you have compiled the libs with java 21 I cannot test if it works on lower versions:

image

KhubaibKhan4 commented 1 month ago

Thank you for your response. I'll check it out on weekend. Hopefully, we will have a progress soon.