chromiumembedded / java-cef

Java Chromium Embedded Framework (JCEF). A simple framework for embedding Chromium-based browsers in other applications using the Java programming language.
https://bitbucket.org/chromiumembedded/java-cef
Other
663 stars 150 forks source link

Provide JavaFX node for JCEF #163

Open magreenblatt opened 9 years ago

magreenblatt commented 9 years ago

Original report by sebastian klaar (Bitbucket: sebastian klaar).


I'd like to use JCEF with JavaFX. It seems not possible to do this via a SwingNode. The only option I see is to provide a JavaFX node instead of AWT.

JavaFX-WebView is not an option, since there is no WebGL support...

magreenblatt commented 3 years ago

Original comment by Jacky Guo (Bitbucket: jgcodes, GitHub: jgcodes).


@{557058:51c10212-0673-4c29-961e-6e6cd8cd250a} I am not very knowledgable about CEF’s APIs or OpenGL, however I have used JavaFX quite a lot (JavaFX 13 and higher). What I posted in the Gist is only part of the idea, as there is probably a way to have CEF render directly to the PixelBuffer instead of hooking into JOGL.

The reason I was throwing this out there is because GLJPanel internally renders OpenGL to a buffer before then transferring the data to the GPU. If CEF can somehow directly render to a ByteBuffer it can bypass this extra copying step, improving performance significantly.

magreenblatt commented 3 years ago

Original comment by Thomas Wilde (Bitbucket: Thomas Wilde).


@Linasch I am able to build from the java cef repository. However, when I build out of yours (https://gitlab.com/linasch/jfx-cef), I get the following error:

CMake Error at CMakeLists.txt:155 (find_package):
By not providing "FindCEF.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CEF", but
CMake did not find one.

Could not find a package configuration file provided by "CEF" with any of
the following names:

CEFConfig.cmake
cef-config.cmake

Add the installation prefix of "CEF" to CMAKE_PREFIX_PATH or set "CEF_DIR"
to a directory containing one of the above files. If "CEF" provides a
separate development package or SDK, be sure it has been installed.

Can you advise on this? Much appreciated!

magreenblatt commented 3 years ago

Original comment by Jacky Guo (Bitbucket: jgcodes, GitHub: jgcodes).


Does CEF use the same buffer for every call to CefRenderer.onPaint()?

magreenblatt commented 3 years ago

Original comment by Former user (Bitbucket: Former user).


@Thomas Wilde i had also troubles, but dont remember the solution. i have copied the result of my build to the directory jcef_build/native/Release

hope this helps

magreenblatt commented 3 years ago

Original comment by Thomas Wilde (Bitbucket: Thomas Wilde).


@Linasch this build works!! What a great FX solution for chromium, it is fast, responsive, and uses less memory than the previous solution. I may have to utilize the original jcef build files instead of a prebuilt solution so it would be fantastic if you were able to remember how to resolve the issue with your build files. Thank you very much for your help and posting the working build.

magreenblatt commented 3 years ago

Original comment by Former user (Bitbucket: Former user).


@Thomas Wilde i think the performance must be the same, then what is the difference between getting the native window by java-cef or by JavaFX for painting?

i copied the changes in repository linasch/jfx-cef branch jfx on GitLab to bitbucket linasch/java-cef branch jfx. all is working as before.and its easier for you to make your own build.

magreenblatt commented 3 years ago

Original comment by Thomas Wilde (Bitbucket: Thomas Wilde).


@Linasch I have played a bit more around with your solution. While your demo application works well, the solution still does not provide a great Node that you can do what you want with. The Node that is provided by CefBrowserFX.getUIComponentFX, does not play well on it’s own if you try to put this in your primary stage - the window creates it’s own decoration and you lose the capability of resizing the window. In your solution, you patch this up by putting the Cef Node in its own stage that is dimensionally binded to another node that acts as a placeholder (cefContainer). This works in your simple solution but causes problems in a more complex application where the node needs to be removed from the scene graph, or when the node is in a tab pane - the stage will still be present rendering the browser. It is possible to account for these things but takes a little bit of effort. What’s interesting is that when you encounter a popup in the browser, a new window is created that is perfectly rendered - how can we create this window from the get go? I still like this solution because it avoids off screen rendering and doesn’t need the keyboarding hack that is required in the Wang solution. However, the SwingNode provided by the Wang solution can be treated as a FX Node right off the bat, whereas this solution cannot.

I’m curious if you tried getting the solution to work without creating a separate Stage. I assume you were unsuccessful and that is why you went that route.

magreenblatt commented 3 years ago

Original comment by Former user (Bitbucket: Former user).


@Thomas Wilde The Stage is the similar component to the component java.awt.Canvas, a heavyweight component, used in CefBrowserWr. I think, its needed because CEF dosn't respect the position of a java.awt.Rectangle (but the width and the height does).

My sample is an implementation of my idea and not a solution out of the box. I did only minimal changes on java-cef. Most of the needed changes are encapsulated on https://gitlab.com/linasch/jfx-cef-sample in FXCef.

The enhancements for more complex situations and potentially integration in java-cef must be done by experts.

Thanks for your tests and interest.

magreenblatt commented 3 years ago

Original comment by Ivan Ooi (Bitbucket: Ivan Ooi).


any prebuild binary? How about solution for Mac? thanks

magreenblatt commented 3 years ago

Original comment by human ardaki (Bitbucket: Human Ardaki).


i think this issue needs a R&D team, do this project have a Discord channel? we can assemble a team for this task for more active development

magreenblatt commented 3 years ago

Original comment by Michele (Bitbucket: Michele, GitHub: Michele).


The fix for EXCEPTION_ACCESS_VIOLATION is to load libGLESv2.dll before all the binaries all loaded. This is because internally this dll looks for libEGL.dll which cannot be found because its path is defined in java.library.path (the dll knows nothing about java paths).

So put this anywere in your main before loading the binaries

System.load(new File(NATIVE_DIRECTORY, "libGLESv2.dll").getAbsolutePath());
System.load(new File(NATIVE_DIRECTORY, "libEGL.dll").getAbsolutePath());

I think only the first line is needed

magreenblatt commented 6 years ago
LansV commented 1 year ago

Is there any new news?

LansV commented 1 year ago

JCEF cannot render in JavaFX 20, only blank page

wmo-v commented 8 months ago

Is there any new news?

leck995 commented 7 months ago

Is there any new news?

timoreichen commented 7 months ago

Is there any new news?

sblingfun commented 7 months ago

Any news on this?