Skip to content
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

[webgui] do not use Edge browser for headless by default #16770

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions gui/webdisplay/src/RWebDisplayHandle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ RWebDisplayHandle::BrowserCreator::Display(const RWebDisplayArgs &args)
}

// use UnixPathName to simplify handling of backslashes
exec = "wmic process call create '"s + gSystem->UnixPathName(fProg.c_str()) + exec + "' | find \"ProcessId\" "s;
exec = "wmic process call create '"s + gSystem->UnixPathName(fProg.c_str()) + " " + exec + "' | find \"ProcessId\" "s;
std::string process_id = gSystem->GetFromPipe(exec.c_str()).Data();
std::stringstream ss(process_id);
std::string tmp;
Expand Down Expand Up @@ -497,8 +497,10 @@ RWebDisplayHandle::ChromeCreator::ChromeCreator(bool _edge) : BrowserCreator(tru
// --no-sandbox is required to run chrome with super-user, but only in headless mode

#ifdef _MSC_VER
// here --headless=old required to let normally end of Edge process when --dump-dom is used
fBatchExec = gEnv->GetValue((fEnvPrefix + "Batch").c_str(), "$prog --headless=old --no-sandbox $geometry --dump-dom $url");
fHeadlessExec = gEnv->GetValue((fEnvPrefix + "Headless").c_str(), "$prog --headless=old --no-sandbox --disable-gpu $geometry \"$url\" &");
// in interactive headless mode fork used to let stop browser via process id
fHeadlessExec = gEnv->GetValue((fEnvPrefix + "Headless").c_str(), "fork:--headless=old --no-sandbox --disable-gpu $geometry \"$url\"");
fExec = gEnv->GetValue((fEnvPrefix + "Interactive").c_str(), "$prog $geometry --new-window --app=$url &"); // & in windows mean usage of spawn
#else
#ifdef R__MACOSX
Expand Down Expand Up @@ -603,7 +605,7 @@ RWebDisplayHandle::FirefoxCreator::FirefoxCreator() : BrowserCreator(true)
// there is a problem when specifying the window size with wmic on windows:
// It gives: Invalid format. Hint: <paramlist> = <param> [, <paramlist>].
fBatchExec = gEnv->GetValue("WebGui.FirefoxBatch", "$prog -headless -no-remote $profile $url");
fHeadlessExec = gEnv->GetValue("WebGui.FirefoxHeadless", "$prog -headless -no-remote $profile $url &");
fHeadlessExec = gEnv->GetValue("WebGui.FirefoxHeadless", "fork:-headless -no-remote $profile \"$url\"");
fExec = gEnv->GetValue("WebGui.FirefoxInteractive", "$prog -no-remote $profile $geometry $url &");
#else
fBatchExec = gEnv->GetValue("WebGui.FirefoxBatch", "$rootetcdir/runfirefox.sh $dumpfile $cleanup_profile $prog --headless -no-remote -new-instance $profile $url 2>/dev/null");
Expand Down Expand Up @@ -806,13 +808,6 @@ std::unique_ptr<RWebDisplayHandle> RWebDisplayHandle::Display(const RWebDisplayA
bool handleAsNative =
(args.GetBrowserKind() == RWebDisplayArgs::kNative) || (args.GetBrowserKind() == RWebDisplayArgs::kOn);

#ifdef _MSC_VER
if (handleAsNative || (args.GetBrowserKind() == RWebDisplayArgs::kEdge)) {
if (try_creator(FindCreator("edge", "ChromeCreator")))
return handle;
}
#endif

if (handleAsNative || (args.GetBrowserKind() == RWebDisplayArgs::kChrome)) {
if (try_creator(FindCreator("chrome", "ChromeCreator")))
return handle;
Expand All @@ -823,6 +818,14 @@ std::unique_ptr<RWebDisplayHandle> RWebDisplayHandle::Display(const RWebDisplayA
return handle;
}

#ifdef _MSC_VER
// Edge browser cannot be run headless without registry change, therefore do not try it by default
if ((handleAsNative && !args.IsHeadless() && !args.IsBatchMode()) || (args.GetBrowserKind() == RWebDisplayArgs::kEdge)) {
if (try_creator(FindCreator("edge", "ChromeCreator")))
return handle;
}
#endif

if ((args.GetBrowserKind() == RWebDisplayArgs::kNative) || (args.GetBrowserKind() == RWebDisplayArgs::kChrome) ||
(args.GetBrowserKind() == RWebDisplayArgs::kFirefox) || (args.GetBrowserKind() == RWebDisplayArgs::kEdge)) {
// R__LOG_ERROR(WebGUILog()) << "Neither Chrome nor Firefox browser cannot be started to provide display";
Expand Down
Loading