Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

Update CEF & WebGL support (Chromium branch) #1415

Open CaptainPRICE opened 4 years ago

CaptainPRICE commented 4 years ago

What?

  1. Update CEF library to latest version.
  2. Please enable WebGL support (opt-in). Test page.
*cough* Why? *cough*

1. Due to security issue which were addressed in newer version. - also, as of this post writing, the currently present CEF in GMod is considered old (in web years). 2. Current CEF version in GMod should support WebGL out-of-box, but still highly recommended to update CEF! Imagine what we could do with WebGL, it would bring a whole lot of new people (Unity) to create high-quality content! First, I want to make nextgen HUD, kick all those crappy (Lua) HUDs in their arse. But, really it would open a whole new world for design and creativity. - also, so i don't have to make another engine modification on top of your engine modification. please. ![image](https://user-images.githubusercontent.com/9789070/65401247-1611b380-ddc7-11e9-8bfc-76f897df1432.png)

*cough* How? *cough*

1. You know how... 2. The following is my suggestion, ```c++ // Introduce a new GMod launch option, and cache a result during engine initialization. static bool g_bRenderChromiumOnGPU; // ... if ( CommandLine()->FindParm( "-cefhq" ) ) { g_bRenderChromiumOnGPU = true; } ``` ```c++ /* This goes in your CefApp class (or wherever you currently disable GPU, compositing, smooth scrolling..). */ virtual void OnBeforeCommandLineProcessing( CefRefPtr app, CefRefPtr command_line ) { // ... if ( IsWindows() && g_bRenderChromiumOnGPU ) { /* Run Chromium renderer on GPU, enable WebGL, etc (for better quality but performance may suffer on low-end PCs). */ command_line->AppendSwitchWithValue( "ignore-gpu-blacklist", "1" ); command_line->AppendSwitchWithValue( "enable-gpu", "1" ); // Enables GPU renderer. command_line->AppendSwitch( "enable-webgl" ); // WebGL power switch. command_line->AppendSwitch( "enable-webgl-swap-chain" ); command_line->AppendSwitch( "enable-webgl2-compute-context" ); //command_line->AppendSwitch( "enable-webgl-draft-extensions" ); // Enable preview WebGL API. command_line->AppendSwitch( "enable-webvr" ); // Enables interaction with virtual reality devices. command_line->AppendSwitch( "disable-gpu-vsync" ); // Going beyond 60 FPS cap. command_line->AppendSwitch( "disable-frame-rate-limit" ); command_line->AppendSwitch( "enable-gpu-rasterization" ); // Enforce rasterization to be performed on GPU. command_line->AppendSwitch( "force-gpu-rasterization" ); command_line->AppendSwitch( "enable-accelerated-2d-canvas" ); // Enables hardware-accelerated 2D canvas. command_line->AppendSwitch( "enable-threaded-compositing" ); command_line->AppendSwitch( "enable-media-stream" ); command_line->AppendSwitch( "enable-mediasource" ); command_line->AppendSwitch( "enable-font-antialiasing" ); command_line->AppendSwitch( "enable-smooth-scrolling" ); //command_line->AppendSwitch( "disable-web-security" ); //command_line->AppendSwitch( "javascript-harmony" ); // Enables Hamony JS (ES6). } else { /* Otherwise, run Chromium renderer on CPU (for better performance). */ command_line->AppendSwitch( "disable-gpu" ); command_line->AppendSwitch( "disable-gpu-compositing" ); command_line->AppendSwitch( "disable-smooth-scrolling" ); command_line->AppendSwitch( "enable-begin-frame-scheduling" ); // Breaks popups. command_line->AppendSwitch( "enable-system-flash" ); command_line->AppendSwitchWithValue( "disable-features", "TouchpadAndWheelScrollLatching,AsyncWheelEvents" ); command_line->AppendSwitch( "disable-gpu-program-cache" ); command_line->AppendSwitch( "disable-notifications" ); //command_line->AppendSwitch( "disable-webgl" ); //command_line->AppendSwitch( "disable-webgl2" ); //command_line->AppendSwitch( "disable-3d-apis" ); //command_line->AppendSwitch( "disable-flash-3d" ); //command_line->AppendSwitch( "disable-flash-stage3d" ); //command_line->AppendSwitch( "disable-pepper-3d" ); //command_line->AppendSwitch( "disable-pepper-3d-image-chromium" ); //command_line->AppendSwitch( "disable-remote-playback-api" ); //command_line->AppendSwitch( "disable-remote-core-animation" ); /* if ( IsLinux() ) { command_line->AppendSwitch( "no-sandbox" ); command_line->AppendSwitch( "no-zygote" ); } */ } // ... } ``` ezpz. An alternative solution would be to create a new file in `cfg` folder, read it, and append the text into CEF command-line. This would in turn, allow a user to fine-tune and manually control CEF switches/flags. I would suggest to have GMod launch option such as `-cefhq` guard still due security measure.

For more details (references / links)...

[List of Chromium Command Line Switches](https://peter.sh/experiments/chromium-command-line-switches/) [Solving Google Chrome's gpu-process error message in Ubuntu Linux](https://simpleit.rocks/linux/ubuntu/fixing-common-google-chrome-gpu-process-error-message-in-linux/)

Bonus fix

In either case, consider enforcing the following CEF command-line switches: `--disable-gpu-process-crash-limit --disable-pinch --disable-touch-adjustment --disable-touch-drag-drop --disable-databases --disable-extensions --disable-logging --disable-crash-reporter --disable-print-preview --disable-speech-api --disable-speech-synthesis-api --disable-sync --disable-breakpad --no-crash-upload --no-report-upload --enable-auto-reload` Depending on how `asset://` protocol is made work, you may want to enforce these too: `--disable-file-system --disable-local-storage`

CaptainPRICE commented 4 years ago

Currently, this is what happens if you try to open the test page in GMod (DHTML). Windows screenshot

meepen commented 4 years ago

Pretty sure it was specifically disabled

swordjjjkkk commented 2 years ago

I need it too.Help us!!

meepen commented 2 years ago

Webgl is disabled for security reasons iirc

On Mon, Aug 9, 2021, 10:37 PM Truman @.***> wrote:

I need it too.Help us!!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Facepunch/garrysmod-requests/issues/1415#issuecomment-895682958, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPGKSJUJJHU6DIXG5TLCY3T4CGHRANCNFSM4IZZOA6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

swordjjjkkk commented 2 years ago

@meepen is there any way to slove this ? like build web to canvas ?

DarthTealc commented 1 month ago

Is there a reason CEF can't be updated on x86-64? @WinterPhoenix and @solsticegamestudios have updated CEF and been maintaining it for years at this point https://github.com/Facepunch/gmod-html/pull/3 - what would be required to merge this?