-
Notifications
You must be signed in to change notification settings - Fork 155
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
Comments
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. |
Original comment by Anand Tiwari (Bitbucket: anandktiwari26, GitHub: anandktiwari26). Hello Sebastian Klaar, CefApp cefApp_ = CefApp.getInstance(); |
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. |
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. |
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 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 |
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. |
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 javax.media.opengl.awt.GLJPanel; public class CefBrowserSample extends Application {
} |
Original comment by DragonWarri0r (Bitbucket: DragonWarri0r, GitHub: DragonWarri0r). @Aaon, it`s works, but very-very slow |
Original comment by Aaron Ong (Bitbucket: Aaron Ong). You'll have to go native if you want a proper JavaFX implementation of JCEF btw |
|
A PR to add this functionality could be accepted if the changes are reasonable in scope. |
Original comment by truejasonxiefans (Bitbucket: truejasonxiefans). Any further news or plan for this feature?. We are suffering from intergrating the JCEF into JavaFX. |
Original comment by Marcus Ataide (Bitbucket: Marcus Ataide). Any news? |
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 |
Original comment by Vinicius Lemes Da Silva (Bitbucket: Vinicius Lemes). Any news on this? |
Original comment by doni mbeng (Bitbucket: jeffartdo). Hello did some have solution about JCEF into JavaFX |
Original comment by ZUchiha Shishui (Bitbucket: zuchiha shishui). Hi Dev. Please add JCEF to JavaFX. Pleaseeeeeeeeeeeeee |
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. |
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? |
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. |
Original comment by Omar Mainegra (Bitbucket: Omar Mainegra). News about this? |
Original comment by Bohdan Shkliarenko (Bitbucket: Bohdan Shkliarenko). What about new PixelBuffer in OpenJFX 13? Or NativeFX project? |
Original comment by Lucas Owen (Bitbucket: Lucas Owen). this needs to be top priority IMO |
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. |
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 |
Issue #381 was marked as a duplicate of this issue. |
Original comment by Peng Liu (Bitbucket: Dapengsechs, GitHub: Dapengsechs).
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.
|
Original comment by Former user (Bitbucket: Former user). Another idea on ‘GitLab.com’, projects ‘jfx-cef' and working example for Windows10 ‘jfx-cef-sample’. |
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. |
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/ ). |
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? |
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.
this works with WebGL and without OSR Mode. |
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. |
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.
this works with WebGL and without OSR Mode. |
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 |
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): Could not find a package configuration file provided by "CEF" with any of
Add the installation prefix of "CEF" to CMAKE_PREFIX_PATH or set "CEF_DIR" Can you advise on this? Much appreciated! |
Original comment by Former user (Bitbucket: Former user).
|
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. |
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. |
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. |
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. |
Original comment by Ivan Ooi (Bitbucket: Ivan Ooi). any prebuild binary? How about solution for Mac? thanks |
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 |
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
I think only the first line is needed |
Is there any new news? |
JCEF cannot render in JavaFX 20, only blank page |
Is there any new news? |
2 similar comments
Is there any new news? |
Is there any new news? |
Any news on this? |
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...
The text was updated successfully, but these errors were encountered: