Repository navigation
Apply --ozone-platform from electron-flags.conf at startup on Linux - #18697
Conversation
|
Thanks for the PR, we'll take a look at it as soon as we can. If you haven't already, please fill out and submit the contributor agreement: https://github.com/rstudio/rstudio/blob/main/CONTRIBUTING.md#contributing-code. |
|
Replaced the unnecessary optional chaining in electron-flags.test.ts. Syntax, focused helper assertions, and whitespace checks passed; lint and the Electron test were unavailable because project-local tools are missing. |
461d298 to
04b0075
Compare
|
@victorwon2001 can you confirm if you've sent a signed CLA over? |
|
Thanks for checking, @kevinushey. I've just emailed my signed individual CLA to [email protected]. |
|
Perfect, thanks! I can confirm we've received it; I'll do one more review. |
kevinushey
left a comment
There was a problem hiding this comment.
Thanks for taking this on -- the diagnosis (Ozone is selected in ElectronBrowserMainParts::PreEarlyInitialization, before the main script can appendSwitch, so only the real argv can influence it) is right, and a one-time relaunch is a reasonable way to get the configured value onto argv.
Review outcome: 4 correctness issues that I think should be addressed before merge (--version/--help now relaunch instead of printing; dev-mode relaunch tears down the forge dev server; an unusable configured value becomes a silent exit 0; conf silently overrides an explicit CLI switch and RSTUDIO_CHROMIUM_ARGUMENTS is not consulted), plus a NEWS placement fix and a few simplifications. Details inline.
Two notes on the PR description:
- typecheck, lint, and the unit tests are listed as blocked, but I ran all three on a scratch worktree of this PR's head (04b0075):
npm run typecheckandnpm run lintare clean, and the new spec passes 8/8 under electron-mocha. So the description and checklist can be updated. - The NEWS entry landed in version/news/os/NEWS-2026.09.0-autumn-hawkbit.md, but this PR targets main (2026.10 / Blue Mistflower), whose notes now live in the root NEWS.md. Please move the entry there (### Fixed).
|
Hi, I'm going to make the suggested fixes and push them to your branch, and see if I can get this PR merged today. |
- Skip the relaunch for --help, --version, and --version-json, and in development builds, where exiting stops electron-forge's dev server - Ignore and log values other than x11/wayland, trim trailing whitespace from electron-flags.conf lines, and log the relaunch - Give --ozone-platform on the command line precedence over RSTUDIO_CHROMIUM_ARGUMENTS, and that over electron-flags.conf; neither re-applies the switch after startup, so child processes match - Decide before R detection and the login-shell query start, and name the file when electron-flags.conf cannot be read - Read the current backend from app.commandLine and append the switch instead of preserving its argv position Addresses rstudio#16594
- Resolve the config directories inside the error handler, so an appData lookup failure reaches the startup error dialog - Honor a final bare --ozone-platform in RSTUDIO_CHROMIUM_ARGUMENTS and report it as unsupported instead of using an earlier value - Compare the Ozone switch to its initial state in the utils test, since Electron sets it on Linux Addresses rstudio#16594
Chromium stops parsing switches at '--', so appending the switch after an argument list like '-- script.R' left it as a plain argument and the relaunched process kept the old backend. Only packaged builds relaunch, and they make no assumption about argv[1]. Addresses rstudio#16594
Chromium treats everything after '--' as a plain argument, so such an argument should not count as the user choosing a backend and suppress the relaunch. Addresses rstudio#16594
kevinushey
left a comment
There was a problem hiding this comment.
Two startup issues need correction: diagnostics loses its terminal output during relaunch, and accepted alternate Ozone switch spellings can restore the browser/child backend mismatch.
Validation: typecheck and lint passed, with two existing lint warnings. The two changed test files had 37 passing tests and one failure because the review worktree lacks an rsession binary. Linux GUI startup remains unverified.
Chromium reads '-ozone-platform' in argv as well as '--ozone-platform', and app.commandLine.appendSwitch, used for RSTUDIO_CHROMIUM_ARGUMENTS and electron-flags.conf, also drops the prefix and lowercases the name. The matchers knew only '--ozone-platform', so '-ozone-platform=x11' or '--OZONE-PLATFORM=x11' could relaunch into one backend and then switch the child processes to another. Addresses rstudio#16594
Electron's Linux relauncher sends the new process's stdout and stderr to /dev/null, which is where diagnostics reports its progress, its errors, and the rsession output. Diagnostics shows no window, so it does not need the configured backend. Addresses rstudio#16594
Intent
Addresses #16594.
On Linux, Chromium picks its Ozone backend before
main.tsruns, so an--ozone-platformfromelectron-flags.confreached only the child processes. RStudio could then open with a blank window.Approach
On packaged Linux builds, startup checks for a requested
--ozone-platformbefore anything else starts (R detection, the login-shell query, startup timing). If the request differs from the backend Chromium started with, RStudio relaunches once with the switch placed ahead of the original arguments.--ozone-platform(or-ozone-platform) on the command line wins, thenRSTUDIO_CHROMIUM_ARGUMENTS, thenelectron-flags.conf. After startup, neither the env var nor the conf file re-applies the switch in any spellingapp.commandLine.appendSwitchaccepts, so child processes match the browser process.x11andwaylandare accepted. Other values are ignored and logged as warnings, and the relaunch decision is printed to the console.--help,--version,--version-json, or--run-diagnostics, whose output would go to/dev/nullin the relaunched process. There's also none in development builds, where exiting stops electron-forge's dev server.electron-flags.confcan't be read, the existing startup error dialog reports its path.The relaunch decision is a pure function,
planOzoneRelaunchinelectron-flags.ts, so its cases are unit-tested.Automated Tests
electron-flags.test.ts: conf parsing and loading (including an unreadable file), and the relaunch cases: matching, differing, and absent backends; env over conf; command line wins; switch spellings; arguments around--; unsupported values; dev builds; no second relaunch.utils.test.ts:augmentCommandLineArgumentsleaves--ozone-platformunchanged.npm run typecheck,npm run lint, andnpm testpass on macOS. Lint reports no errors and two warnings already on main, insession-launcher.test.ts.QA Notes
Not yet verified on Linux. With
--ozone-platform=waylandin~/.config/rstudio/electron-flags.conf:rstudio --ozone-platform=x11stays on X11.rstudio --versionprints the version and exits without relaunching.--ozone-platform=bogusinstead, RStudio starts on its default backend and rdesktop.log has the warning.Checklist
NEWS.md