In JxBrowser 6.10 and higher there's an option that allows enabling accelerated lightweight rendering mode. This rendering mode has improved performance compared to default lightweight rendering mode. It allows producing ~30% more frames per second.(在JxBrowser 6.10及更高版本中,有一个选项允许启用加速的轻量级渲染模式。与默认的轻量级渲染模式相比,此渲染模式具有更高的性能。它允许每秒多产生约30%的帧。)


Accelerated lightweight rendering is faster than the ordinary lightweight rendering, as in the accelerated mode rendering is performed directly in RAM. The ordinary lightweight mode uses a video card where there is a phase of copying an image from video memory to RAM.  As the stage of copying from video memory to RAM is absent in the accelerated lightweight mode, we can see an increase in speed. (加速轻量级渲染比普通轻量级渲染更快,因为在加速模式下渲染直接在RAM中执行。 普通的轻量模式使用视频卡,其中有一个将图像从视频内存复制到RAM的阶段。 由于在加速轻量模式下没有从视频内存复制到RAM的阶段,我们可以看到速度有所提高)


Important: the only disadvantage of this accelerated rendering mode is that it doesn't support WebGL, because GPU process isn't used in this case. If you don't need to display web pages with WebGL, we recommend that you enable and use accelerated lightweight rendering mode.(重要提示:这种加速渲染模式的唯一缺点是它不支持WebGL,因为在这种情况下不使用GPU进程。如果不需要使用WebGL显示网页,建议您启用并使用加速的轻量级渲染模式。)


To enable accelerated lightweight rendering mode you must specify the following Chromium switches before you create the first Browser instance in your application:(要启用加速的轻量级渲染模式,必须在创建应用程序中的第一个Browser实例之前指定以下Chromium开关:)

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserPreferences;
import com.teamdev.jxbrowser.chromium.BrowserType;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

import javax.swing.*;
import java.awt.*;

public class AcceleratedLightweightRenderingSample {
    public static void main(String[] args) {
        BrowserPreferences.setChromiumSwitches(
                "--disable-gpu",
                "--disable-gpu-compositing",
                "--enable-begin-frame-scheduling",
                "--software-rendering-fps=60"
        );

        Browser browser = new Browser(BrowserType.LIGHTWEIGHT);
        BrowserView view = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(1100, 750);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        browser.loadURL("https://www.youtube.com/watch?v=lfwjzNB--5k");
    }
}