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

Provide JavaFX node for JCEF #163

Open
magreenblatt opened this issue Mar 20, 2015 · 68 comments
Open

Provide JavaFX node for JCEF #163

magreenblatt opened this issue Mar 20, 2015 · 68 comments
Labels
enhancement Enhancement request

Comments

@magreenblatt
Copy link
Collaborator

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
Copy link
Collaborator Author

Original comment by Patrick Sweeney (Bitbucket: Klobersaurus).


I have been wanting this for months. The JavaFX WebView is not cutting it from a Javascript performance standpoint. I also tried with the SwingNode but JCEF would not render, at all. SwingNode has a disclaimer saying that it cannot render anything too complicated.

@magreenblatt
Copy link
Collaborator Author

Original comment by Anand Tiwari (Bitbucket: anandktiwari26, GitHub: anandktiwari26).


Hello Sebastian Klaar,
Try it.

CefApp cefApp_ = CefApp.getInstance();
CefClient client_ = cefApp_.createClient();
CefBrowser browser_ = client_.createBrowser("https://www.google.com", OS.isLinux(), false);
Component browerUI_ = browser_.getUIComponent();
JPanel panel = new JPanel();
panel.add(browerUI_);
SwingNode swingNode = new SwingNode();
swingNode.setContent(panel);

@magreenblatt
Copy link
Collaborator Author

Original comment by Patrick Sweeney (Bitbucket: Klobersaurus).


Anand Tiwari, I just tried this and had no luck. Did you actually manage to get this to work? I'm developing against JDK8u40 64-bit on Windows 7.

@magreenblatt
Copy link
Collaborator Author

Here's some information on JOGL's attempts to integrate with JavaFX: https://jogamp.org/bugzilla/show_bug.cgi?id=607. Sounds like using JOGL + JavaFX on Windows at least is not currently possible, so we would be looking at developing an alternative JavaFX-based off-screen rendering implementation to completely replace the JOGL usage. I'm not sure what would be required to support windowed JCEF with JavaFX or if that even makes sense given JavaFX's intended usage.

@magreenblatt
Copy link
Collaborator Author

Original comment by Roberto Neto (Bitbucket: BetoN, GitHub: BetoN).


Any news for this issue?

@magreenblatt
Copy link
Collaborator Author

Original comment by Aaron Ong (Bitbucket: Aaron Ong).


Hi. I needed to embed CEF into our pre-existing JavaFX UI as well, so I did a little experimenting. What worked for me was going into the CefBrowserOsr.java file, and changing the type of canvas_ from GLCanvas to GLJPanel, which is a lightweight component that's compatible with JavaFX's SwingNode. The two classes seem to be mostly equivalent, so you don't have to change any method calls to canvas_.

The only caveat with this approach is that you must use OSR mode for this to work, but I'll take anything I can get at this point. I also haven't checked if there are any side effects, but I've tested it a bit so far and it seems to be enough for our use case.

Edit: The only issue I've seen so far is that backspace, tab, and certain other keys don't work when embedded in a SwingNode, but they do when using Swing.

@magreenblatt
Copy link
Collaborator Author

Original comment by Aaron Ong (Bitbucket: Aaron Ong).


I did a little more digging, and it turns out that the problem with the backspace key was due to JavaFX's different way of handling key events. It took a bit of hackery, but I created a new SwingNode class that overrides the default key handling behavior of the original JavaFX version: http://pastebin.com/EA26Mz6m

The main difference here starts at line 45, where it just copies the key code value (cast into a char) to the key char value if key char's integer value is 0. I'm not sure if this is entirely correct, but I was able to get backspace to work, at least.

@magreenblatt
Copy link
Collaborator Author

Original comment by Roberto Neto (Bitbucket: BetoN, GitHub: BetoN).


@Aaon, can you provide a simple example ?

@magreenblatt
Copy link
Collaborator Author

Original comment by Aaron Ong (Bitbucket: Aaron Ong).


I can't test this right now because I don't have the right environment. This one uses the modified SwingNode I provided to make the backspace key work. Some other keys still don't work correctly though, so I guess it still needs some more remapping.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import org.cef.CefApp;
import org.cef.CefClient;
import org.cef.browser.CefBrowser;

import javax.media.opengl.awt.GLJPanel;

public class CefBrowserSample extends Application {

@Override
public void start( Stage primaryStage ) {
    Pane root = new Pane();
    SwingNode swingNode = new SwingNode();
    root.getChildren().add( swingNode );
    Scene scene = new Scene( root, 500, 500 );
    primaryStage.setTitle( "JCEF Example" );
    primaryStage.setScene( scene );

    CefApp app = CefApp.getInstance();
    CefClient client = app.createClient();
    CefBrowser browser = client.createBrowser( "www.google.com", true, false );
    swingNode.setContent( ( GLJPanel) browser.getUIComponent() );

    primaryStage.show();
}

public static void main( String[] args ) {
    launch( args );
}

}

@magreenblatt
Copy link
Collaborator Author

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


@Aaon, it`s works, but very-very slow

@magreenblatt
Copy link
Collaborator Author

Original comment by Aaron Ong (Bitbucket: Aaron Ong).


You'll have to go native if you want a proper JavaFX implementation of JCEF btw

@magreenblatt
Copy link
Collaborator Author

  • changed title from "Povide JavaFX node for JCEF" to "Provide JavaFX node for JCEF"

@magreenblatt
Copy link
Collaborator Author

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


Any news for this issue?

@magreenblatt
Copy link
Collaborator Author

Original comment by iltaf khalid (Bitbucket: iltaf, GitHub: iltaf).


I am also stuck at this point on integrating JavaFX with JCEF. I wish JCEF guys natively support JavaFX so that we avoid all the hacks while compromising on performance etc.

@magreenblatt
Copy link
Collaborator Author

A PR to add this functionality could be accepted if the changes are reasonable in scope.

@magreenblatt
Copy link
Collaborator Author

Original comment by truejasonxiefans (Bitbucket: truejasonxiefans).


Any further news or plan for this feature?. We are suffering from intergrating the JCEF into JavaFX.

@magreenblatt
Copy link
Collaborator Author

Original comment by Marcus Ataide (Bitbucket: Marcus Ataide).


Any news?

@magreenblatt
Copy link
Collaborator Author

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


Is there any news about this issue?

Also, I see from earlier comments that many people wanted this feature long time ago. Is there anyone who can share if they found a hack/temporary solution? Is it possible to get a not perfect but decent performance in JavaFX?

@magreenblatt
Copy link
Collaborator Author

Original comment by Jakub Šmíd (Bitbucket: xjakubs, GitHub: xjakubs).


any news? I tried JxBrowser, but it is licensed :-(

@magreenblatt
Copy link
Collaborator Author

Original comment by Vinicius Lemes Da Silva (Bitbucket: Vinicius Lemes).


Any news on this?

@magreenblatt
Copy link
Collaborator Author

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


any news?

@magreenblatt
Copy link
Collaborator Author

Original comment by doni mbeng (Bitbucket: jeffartdo).


Hello did some have solution about JCEF into JavaFX

@magreenblatt
Copy link
Collaborator Author

Original comment by ZUchiha Shishui (Bitbucket: zuchiha shishui).


Hi Dev. Please add JCEF to JavaFX. Pleaseeeeeeeeeeeeee

@magreenblatt
Copy link
Collaborator Author

Original comment by Chigozirim Chukwu (Bitbucket: smac89, GitHub: smac89).


There is a promising project which could potentially allow one to embed a GLCanvas in a javafx node (not SwingNode).

https://github.com/eclipse-efx/efxclipse-drift

I have a ready-to-go fork which uses gradle to run the application so you can see it in action:

https://github.com/smac89/efxclipse-drift

If anyone has the know-how, they can contribute to this project so that we can see this happen sooner than later.

@magreenblatt
Copy link
Collaborator Author

Original comment by ZUchiha Shishui (Bitbucket: zuchiha shishui).


This issue have existed since 2015, now In 2019, They couldn’t fixed it. What are they doing?

@magreenblatt
Copy link
Collaborator Author

Original comment by Dominik (Bitbucket: domino2, GitHub: domino2).


From my view of perspective, this should be highly prioritize as web technologies are taking over the desktop for long time already and I suppose that we want to keep Java as good desktop gui as it was. Out there are not so good GUI frameworks and result of this issue can boost right direction and potentially offer nice transferability to different CEF implementation.

@magreenblatt
Copy link
Collaborator Author

Original comment by Omar Mainegra (Bitbucket: Omar Mainegra).


News about this?

@magreenblatt
Copy link
Collaborator Author

Original comment by Bohdan Shkliarenko (Bitbucket: Bohdan Shkliarenko).


What about new PixelBuffer in OpenJFX 13? Or NativeFX project?
I saw some experiments with new PixelBuffer and vlcj (https://twitter.com/hashtag/vlcj)
I think we all are getting closer to use cef project inside JavaFX without swing.

@magreenblatt
Copy link
Collaborator Author

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


News about this?

@magreenblatt
Copy link
Collaborator Author

Original comment by Lucas Owen (Bitbucket: Lucas Owen).


this needs to be top priority IMO

@magreenblatt
Copy link
Collaborator Author

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


Sorry, I haven’t made a demo yet. I might see if I can figure something out.

EDIT: see proposal #381 for a general idea of the internal workings. I have yet to find a buffer to work off of.

@magreenblatt
Copy link
Collaborator Author

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


@{557058:2f2a2aee-b500-4023-9734-037e9897c3ab} and others, this is a rough sketch of how PixelBuffer can be used to skip the JOGL usage when it comes to JFX.

https://gist.github.com/jgcodes2020/e5d99fbf9aa6bfcf7f1f9d53b60d4eb8

@magreenblatt
Copy link
Collaborator Author

Issue #381 was marked as a duplicate of this issue.

@magreenblatt
Copy link
Collaborator Author

Original comment by Peng Liu (Bitbucket: Dapengsechs, GitHub: Dapengsechs).


Aaron Ong

Hi. I needed to embed CEF into our pre-existing JavaFX UI as well, so I did a little experimenting. What worked for me was going into the CefBrowserOsr.java file, and changing the type of canvas_ from GLCanvas to GLJPanel, which is a lightweight component that's compatible with JavaFX's SwingNode. The two classes seem to be mostly equivalent, so you don't have to change any method calls to canvas_.

The only caveat with this approach is that you must use OSR mode for this to work, but I'll take anything I can get at this point. I also haven't checked if there are any side effects, but I've tested it a bit so far and it seems to be enough for our use case.

Edit: The only issue I've seen so far is that backspace, tab, and certain other keys don't work when embedded in a SwingNode, but they do when using Swing.

2017-03-10

Yes, the solution of Aaron Ong works perfect when the off-screen mode is true.

How can we make it also work for not-off-screen (off-screen mode is false)? i.e. using CefBrowserWr.java?

Because applying the same modification above to CefBrowserWr.java doen’t work. But withou necessary modification an error will be thrown.

org.cef.browser.CefBrowserWr$3 cannot be cast to com.jogamp.opengl.awt.GLJPanel

Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: org.cef.browser.CefBrowserWr$3 cannot be cast to com.jogamp.opengl.awt.GLJPanel
	at org.charts.dataviewer.javafx.jcef.CefWebview.getBrowser(CefWebview.java:43)
	at org.charts.dataviewer.javafx.jcef.CefWebview.load(CefWebview.java:30)
	at org.charts.dataviewer.javafx.JavaFxDataViewer.createCefView(JavaFxDataViewer.java:51)
	at org.charts.dataviewer.javafx.JavaFxDataViewer.<init>(JavaFxDataViewer.java:39)
	at eu.akka.ptsw.fleetcommander.view.charts.JavaFxDataViewerFactory.createMapPlot(JavaFxDataViewerFactory.java:197)
	at eu.akka.ptsw.dletnt.javafx.plotly.factory.TestMapPlot.showVehicleMapPlot(TestMapPlot.java:123)
	at eu.akka.ptsw.dletnt.javafx.plotly.factory.TestMapPlot.lambda$0(TestMapPlot.java:60)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Node.fireEvent(Node.java:8411)
	at javafx.scene.control.Button.fire(Button.java:185)
	at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
	at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
	at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
	at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
	at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
	at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
	at com.sun.glass.ui.View.notifyMouse(View.java:937)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177)
	at java.lang.Thread.run(Thread.java:748)

@magreenblatt
Copy link
Collaborator Author

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


Another idea on ‘GitLab.com’, projects ‘jfx-cef' and working example for Windows10 ‘jfx-cef-sample’.

@magreenblatt
Copy link
Collaborator Author

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


@linasch are you talking about this? https://gitlab.com/linasch/jfx-cef/-/tree/jfx

Feel free to copy your repo to Bitbucket and submit a PR.

@magreenblatt
Copy link
Collaborator Author

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


@jacky Guo this link: https://gitlab.com/linasch/jfx-cef (Mirrored from https://bitbucket.org/chromiumembedded/java-cef/src/master/ ). CefBrowserWrFX extends CefBrowserWr (without offscreen mode). working example: https://gitlab.com/linasch/jfx-cef-sample

@magreenblatt
Copy link
Collaborator Author

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


I tried this example but get the following error.

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000714c4f57, pid=22952, tid=0x0000000000004aec

However, I am using the Jcef build from the build provided in the working SwingNode example I previously mentioned: https://github.com/wang9426/FxJCEF.

Perhaps I need to go through the cmake build in the gitlab project?

@magreenblatt
Copy link
Collaborator Author

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


@{557058:51c10212-0673-4c29-961e-6e6cd8cd250a} https://github.com/wang9426/FxJCEF is another approach that dont fit. The build must be done out of https://gitlab.com/linasch/jfx-cef and then can be used by  https://gitlab.com/linasch/jfx-cef-sample.

  • for the native part i used CMake GUI and Visual Studio 2019 (changed only CefBrowser_N.cpp)
  • the java part Eclipse 2020-06 and jdk1.8.0_192 (new: java/org/cef/browser/CefBrowserFX.java extends CefBrowser
    changed: java/org/cef/browser/CefBrowserFactory.java
    new java/org/cef/browser/CefBrowserWrFX.java extends CefBrowserWr

this works with WebGL and without OSR Mode.

@magreenblatt
Copy link
Collaborator Author

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


@linasch Thanks for the info. Would you mind posting your build? I would love to test it and compare the performance to the previous SwingNode with osr solution.

@magreenblatt
Copy link
Collaborator Author

Original comment by Martin (Bitbucket: natschz, GitHub: natschz).


Are there any advancements regarding this? Or is there a solution that is working right now?

@magreenblatt
Copy link
Collaborator Author

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


JCEF in JavaFX Summary:


Method 1: Confirmed working by Thomas Wilde

Working JCEF in JavaFX, CEF already built:

https://github.com/wang9426/FxJCEF

Minor Drawbacks: slightly slow but really not bad. Tabbing inside the browser does not work. I have been using this in my projects for some time (JDK8)

One problem I have with this is if I take the Browser off of a scene, when I bring it back it no longer renders and I have to start a new browser. I made a listener with ReActFX to load a new browser when the browser is brought back to the scene. This isn’t extremely bad except for when I user is logged into a website, they will then have to log in again.


Method 2: Has not been confirmed as far as I’m aware

Unconfirmed method, using PixelBuffer in JDK11+ instead of swingnode

https://gist.github.com/jgcodes2020/e5d99fbf9aa6bfcf7f1f9d53b60d4eb8


Method 3: Confirmed to work by Linasch but I have not personally built it and confirmed. Curious on the performance and if this is prefered to Method 1.

https://gitlab.com/linasch/jfx-cef and then can be used by  https://gitlab.com/linasch/jfx-cef-sample.

  • for the native part i used CMake GUI and Visual Studio 2019 (changed only CefBrowser_N.cpp)
  • the java part Eclipse 2020-06 and jdk1.8.0_192 (new: java/org/cef/browser/CefBrowserFX.java extends CefBrowser
    changed: java/org/cef/browser/CefBrowserFactory.java
    new java/org/cef/browser/CefBrowserWrFX.java extends CefBrowserWr

this works with WebGL and without OSR Mode.

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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


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

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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


any prebuild binary? How about solution for Mac? thanks

@magreenblatt
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@LansV
Copy link

LansV commented Oct 23, 2023

Is there any new news?

@LansV
Copy link

LansV commented Oct 23, 2023

JCEF cannot render in JavaFX 20, only blank page

@wmo-v
Copy link

wmo-v commented Mar 21, 2024

Is there any new news?

2 similar comments
@leck995
Copy link

leck995 commented Apr 16, 2024

Is there any new news?

@timoreichen
Copy link

Is there any new news?

@sblingfun
Copy link

Any news on this?

@chromiumembedded chromiumembedded locked as spam and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhancement request
Projects
None yet
Development

No branches or pull requests

6 participants