Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for accelerated (GPU/shared-texture) windowless rendering and external begin-frame driving, extending both the native CEF callbacks and the Java-facing JCEF API surface to carry platform-specific GPU resource information.
Changes:
- Implement
CefRenderHandler::OnAcceleratedPaintnative-to-Java bridging with new JavaCefAcceleratedPaintInfo*data structures. - Add
CefBrowser#sendExternalBeginFrame()and plumb newCefBrowserSettingsflags (shared_texture_enabled,external_begin_frame_enabled) into native browser creation. - Introduce a public
CefBrowserWindowlessbase class and update OSR messaging/tooling (.gitignore, clone script, README formatting).
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| native/render_handler.h | Declares native OnAcceleratedPaint override. |
| native/render_handler.cpp | Implements accelerated paint JNI bridging and Linux dmabuf plane mapping. |
| native/jni_util.h | Declares SetJNIFieldLong helper. |
| native/jni_util.cpp | Implements SetJNIFieldLong. |
| native/CefBrowser_N.h | Declares JNI export for N_SendExternalBeginFrame. |
| native/CefBrowser_N.cpp | Plumbs OSR parent handle derivation and new windowless flags; adds native begin-frame call. |
| java/org/cef/handler/CefRenderHandlerAdapter.java | Adds no-op accelerated paint + listener hooks to adapter. |
| java/org/cef/handler/CefRenderHandler.java | Adds accelerated paint callback + listener method defaults. |
| java/org/cef/handler/CefAcceleratedPaintInfo.java | Adds base accelerated paint info DTO. |
| java/org/cef/handler/CefAcceleratedPaintInfoWin.java | Windows-specific shared texture handle DTO. |
| java/org/cef/handler/CefAcceleratedPaintInfoMac.java | macOS-specific IOSurface handle DTO. |
| java/org/cef/handler/CefAcceleratedPaintInfoLinux.java | Linux dmabuf plane metadata DTO. |
| java/org/cef/browser/CefBrowser_N.java | Adds Java wrapper for sendExternalBeginFrame() native call. |
| java/org/cef/browser/CefBrowserWr.java | Throws unsupported for begin-frame on windowed browsers. |
| java/org/cef/browser/CefBrowserWindowless.java | New public base class for custom windowless browser implementations. |
| java/org/cef/browser/CefBrowserFactory.java | Updates OSR error message to guide users to CefBrowserWindowless. |
| java/org/cef/browser/CefBrowser.java | Adds sendExternalBeginFrame() API to the interface. |
| java/org/cef/browser/CefAcceleratedPaintEvent.java | Adds event wrapper for accelerated paint callbacks. |
| java/org/cef/CefClient.java | Forwards onAcceleratedPaint to the real render handler. |
| java/org/cef/CefBrowserSettings.java | Adds and clones new OSR flags. |
| clone_cef.sh | Adds helper script to clone upstream CEF into /cef. |
| README.md | Markdown list formatting cleanup. |
| .gitignore | Ignores /cef directory created by clone script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SetJNIFieldInt(env, cls, jpaintInfo, "format", info.format); | ||
| SetJNIFieldInt(env, cls, jpaintInfo, "width", viewRect.width); | ||
| SetJNIFieldInt(env, cls, jpaintInfo, "height", viewRect.height); |
There was a problem hiding this comment.
OnAcceleratedPaint sets the Java paint info width/height from GetViewRect() (viewRect.width/height). This will be incorrect for PET_POPUP (and may diverge from the actual shared-texture dimensions). Consider populating width/height based on the painted element (e.g., popup size when type==PET_POPUP) or using dimensions provided by the accelerated paint info if available, so Java consumers (e.g., CefAcceleratedPaintEvent#getWidth/Height) receive accurate values.
| jfieldID fdsField = env->GetFieldID(cls, "plane_fds", "[I"); | ||
| jfieldID stridesField = env->GetFieldID(cls, "plane_strides", "[I"); | ||
| jfieldID offsetsField = env->GetFieldID(cls, "plane_offsets", "[J"); | ||
| jfieldID sizesField = env->GetFieldID(cls, "plane_sizes", "[J"); |
There was a problem hiding this comment.
JNIEnv::GetFieldID will raise a pending Java exception (NoSuchFieldError) when a field is missing. Here the results are checked, but any pending exception is not cleared/handled before continuing, which can cause the later JNI_CALL_VOID_METHOD to fail silently. Please clear the exception and return early (or use a helper that clears exceptions) when any GetFieldID call fails.
| jfieldID fdsField = env->GetFieldID(cls, "plane_fds", "[I"); | |
| jfieldID stridesField = env->GetFieldID(cls, "plane_strides", "[I"); | |
| jfieldID offsetsField = env->GetFieldID(cls, "plane_offsets", "[J"); | |
| jfieldID sizesField = env->GetFieldID(cls, "plane_sizes", "[J"); | |
| jfieldID fdsField = env->GetFieldID(cls, "plane_fds", "[I"); | |
| if (!fdsField && env->ExceptionCheck()) | |
| env->ExceptionClear(); | |
| jfieldID stridesField = env->GetFieldID(cls, "plane_strides", "[I"); | |
| if (!stridesField && env->ExceptionCheck()) | |
| env->ExceptionClear(); | |
| jfieldID offsetsField = env->GetFieldID(cls, "plane_offsets", "[J"); | |
| if (!offsetsField && env->ExceptionCheck()) | |
| env->ExceptionClear(); | |
| jfieldID sizesField = env->GetFieldID(cls, "plane_sizes", "[J"); | |
| if (!sizesField && env->ExceptionCheck()) | |
| env->ExceptionClear(); |
| jlongArray offsetsArray = env->NewLongArray(plane_count); | ||
| jlongArray sizesArray = env->NewLongArray(plane_count); | ||
|
|
||
| if (fdsArray && stridesArray && offsetsArray && sizesArray) { |
There was a problem hiding this comment.
The NewIntArray/NewLongArray calls can throw (e.g., OOME) and leave a pending JNI exception. The code currently just checks for null and continues, which will keep the exception pending and break subsequent JNI calls. Consider checking env->ExceptionCheck() (or clearing and returning) if any array allocation fails.
| if (fdsArray && stridesArray && offsetsArray && sizesArray) { | |
| // NewIntArray/NewLongArray may throw (e.g., OOME) and leave a pending | |
| // exception. Clear any such exception and only proceed when no | |
| // exception is pending and all arrays were allocated successfully. | |
| if (env->ExceptionCheck()) { | |
| env->ExceptionClear(); | |
| } else if (fdsArray && stridesArray && offsetsArray && sizesArray) { |
No description provided.