Skip to content

Commit

Permalink
Merge pull request #395 from sashka/main
Browse files Browse the repository at this point in the history
Make --disable-gpu not hard coded
  • Loading branch information
mdrokz committed Jun 28, 2023
2 parents f127f42 + 5ed6fcc commit 38858c9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/browser/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ pub struct LaunchOptions<'a> {
#[builder(default = "true")]
pub sandbox: bool,

/// Determines whether to enable GPU or not. Default to false.
#[builder(default = "false")]
pub enable_gpu: bool,

/// Determines whether to run the browser with logging enabled
/// (this can cause unwanted new shell window in Windows 10 and above).
/// Check <https://github.com/rust-headless-chrome/rust-headless-chrome/issues/371>
Expand Down Expand Up @@ -165,6 +169,7 @@ impl<'a> Default for LaunchOptions<'a> {
LaunchOptions {
headless: true,
sandbox: true,
enable_gpu: false,
enable_logging: false,
idle_browser_timeout: Duration::from_secs(30),
window_size: None,
Expand Down Expand Up @@ -316,7 +321,6 @@ impl Process {

let mut args = vec![
port_option.as_str(),
"--disable-gpu",
"--verbose",
"--log-level=0",
"--no-first-run",
Expand Down Expand Up @@ -353,6 +357,10 @@ impl Process {
args.extend(["--enable-logging"]);
}

if !launch_options.enable_gpu {
args.extend(["--disable-gpu"]);
}

let proxy_server_option = if let Some(proxy_server) = launch_options.proxy_server {
format!("--proxy-server={proxy_server}")
} else {
Expand Down

0 comments on commit 38858c9

Please sign in to comment.