Bug 1875773 - [geckodriver] Add command line argument to enable crash reporter for diagnostic purposes. r=whimboo,webdriver-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D200140
This commit is contained in:
Razvan Cojocaru 2024-02-12 12:23:58 +00:00
parent ea5dd880a4
commit 1c508cea14
5 changed files with 49 additions and 18 deletions

View File

@ -50,3 +50,16 @@ crash report to the geckodriver issue.
[crash reporter]: https://support.mozilla.org/kb/mozillacrashreporter#w_viewing-reports-outside-of-firefox
[view the crash reports]: https://support.mozilla.orgkb/mozillacrashreporter#w_viewing-crash-reports
## Enabling the crash reporter
By default geckodriver disables the crash reporter so it doesn't submit crash
reports to Mozilla's crash reporting system, and also doesn't interfere with
testing.
This behaviour can be overridden by using the command line argument
`--enable-crash-reporter`. You can [view the crash reports] and share it with
us after submission.
**Important**: Please only enable the crash reporter if the above mentioned
solution does not work.

View File

@ -258,6 +258,7 @@ impl AndroidHandler {
&self,
args: Option<Vec<String>>,
envs: I,
enable_crash_reporter: bool,
) -> Result<String>
where
I: IntoIterator<Item = (K, V)>,
@ -290,18 +291,20 @@ impl AndroidHandler {
);
}
config.env.insert(
Value::String("MOZ_CRASHREPORTER".to_owned()),
Value::String("1".to_owned()),
);
config.env.insert(
Value::String("MOZ_CRASHREPORTER_NO_REPORT".to_owned()),
Value::String("1".to_owned()),
);
config.env.insert(
Value::String("MOZ_CRASHREPORTER_SHUTDOWN".to_owned()),
Value::String("1".to_owned()),
);
if !enable_crash_reporter {
config.env.insert(
Value::String("MOZ_CRASHREPORTER".to_owned()),
Value::String("1".to_owned()),
);
config.env.insert(
Value::String("MOZ_CRASHREPORTER_NO_REPORT".to_owned()),
Value::String("1".to_owned()),
);
config.env.insert(
Value::String("MOZ_CRASHREPORTER_SHUTDOWN".to_owned()),
Value::String("1".to_owned()),
);
}
let mut contents: Vec<String> = vec![CONFIG_FILE_HEADING.to_owned()];
contents.push(serde_yaml::to_string(&config)?);
@ -314,6 +317,7 @@ impl AndroidHandler {
profile: &Profile,
args: Option<Vec<String>>,
env: I,
enable_crash_reporter: bool,
) -> Result<()>
where
I: IntoIterator<Item = (K, V)>,
@ -340,7 +344,7 @@ impl AndroidHandler {
.device
.push_dir(&profile.path, &self.profile, 0o777)?;
let contents = self.generate_config_file(args, env)?;
let contents = self.generate_config_file(args, env, enable_crash_reporter)?;
debug!("Content of generated GeckoView config file:\n{}", contents);
let reader = &mut io::BufReader::new(contents.as_bytes());

View File

@ -73,6 +73,7 @@ impl LocalBrowser {
marionette_port: u16,
jsdebugger: bool,
profile_root: Option<&Path>,
enable_crash_reporter: bool,
) -> WebDriverResult<LocalBrowser> {
let binary = options.binary.ok_or_else(|| {
WebDriverError::new(
@ -124,10 +125,12 @@ impl LocalBrowser {
}
// https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
runner
.env("MOZ_CRASHREPORTER", "1")
.env("MOZ_CRASHREPORTER_NO_REPORT", "1")
.env("MOZ_CRASHREPORTER_SHUTDOWN", "1");
if !enable_crash_reporter {
runner
.env("MOZ_CRASHREPORTER", "1")
.env("MOZ_CRASHREPORTER_NO_REPORT", "1")
.env("MOZ_CRASHREPORTER_SHUTDOWN", "1");
}
let process = match runner.start() {
Ok(process) => process,
@ -240,6 +243,7 @@ impl RemoteBrowser {
marionette_port: u16,
websocket_port: Option<u16>,
profile_root: Option<&Path>,
enable_crash_reporter: bool,
) -> WebDriverResult<RemoteBrowser> {
let android_options = options.android.unwrap();
@ -271,7 +275,7 @@ impl RemoteBrowser {
)
})?;
handler.prepare(&profile, options.args, options.env.unwrap_or_default())?;
handler.prepare(&profile, options.args, options.env.unwrap_or_default(), enable_crash_reporter)?;
handler.launch()?;

View File

@ -254,6 +254,7 @@ fn parse_args(args: &ArgMatches) -> ProgramResult<Operation> {
allow_hosts: allow_hosts.clone(),
allow_origins: allow_origins.clone(),
jsdebugger: args.get_flag("jsdebugger"),
enable_crash_reporter: args.get_flag("enable_crash_reporter"),
android_storage,
};
Ok(Operation::Server {
@ -379,6 +380,12 @@ fn make_command() -> Command {
.action(ArgAction::SetTrue)
.help("Connect to an existing Firefox instance"),
)
.arg(
Arg::new("enable_crash_reporter")
.long("enable-crash-reporter")
.action(ArgAction::SetTrue)
.help("Enable the Firefox crash reporter for diagnostic purposes"),
)
.arg(
Arg::new("help")
.short('h')

View File

@ -102,6 +102,7 @@ pub(crate) struct MarionetteSettings {
/// letting you debug internals.
pub(crate) jsdebugger: bool,
pub(crate) enable_crash_reporter: bool,
pub(crate) android_storage: AndroidStorageInput,
}
@ -199,6 +200,7 @@ impl MarionetteHandler {
marionette_port,
websocket_port,
self.settings.profile_root.as_deref(),
self.settings.enable_crash_reporter,
)?)
} else if !self.settings.connect_existing {
Browser::Local(LocalBrowser::new(
@ -206,6 +208,7 @@ impl MarionetteHandler {
marionette_port,
self.settings.jsdebugger,
self.settings.profile_root.as_deref(),
self.settings.enable_crash_reporter,
)?)
} else {
Browser::Existing(marionette_port)