Skip to content

Commit 22aee12

Browse files
authored
Improve Firefox browser process tracking (#25644)
Improve Firefox browser process tracking by using the -wait-for-browser cmdline arg, and waiting longer for process startup. Unfortunately `-wait-for-browser` is not enough to get rid of the process delta polling, since the process handle returned by `subprocess.Popen()` cannot be used to cascade the spawned Firefox windows. Waiting for 2 seconds for Firefox startup was not enough, so make the wait time more conservative. Add the detected processes to the list rather than replace, so that all process handles are retained. It may be possible to remove the use of `launch_browser_harness_with_proc_snapshot_workaround()` for headless Firefox runs, but more testing will be needed to verify that.
1 parent 8690df6 commit 22aee12

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎test/common.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def configure(data_dir):
137137

138138
class FirefoxConfig:
139139
data_dir_flag = '-profile '
140-
default_flags = ('-new-instance',)
140+
default_flags = ('-new-instance', '-wait-for-browser') if WINDOWS else ('-new-instance',)
141141
headless_flags = '-headless'
142142
executable_name = utils.exe_suffix('firefox')
143143

@@ -2081,13 +2081,13 @@ def launch_browser_harness_with_proc_snapshot_workaround(cls, parallel_harness,
20812081
# Give the browser time to spawn its subprocesses. Use an increasing
20822082
# timeout as a crude way to account for system load.
20832083
if parallel_harness or is_safari():
2084-
time.sleep(min(2 + count * 0.3, 10))
2084+
time.sleep(min(5 + count * 0.3, 10))
20852085
procs_after = list_processes_by_name(config.executable_name)
20862086

20872087
# Take a snapshot again to find which processes exist after launching
20882088
# the browser. Then the newly launched browser processes are determined
20892089
# by the delta before->after.
2090-
cls.browser_procs = list(set(procs_after).difference(set(procs_before)))
2090+
cls.browser_procs += list(set(procs_after).difference(set(procs_before)))
20912091
if len(cls.browser_procs) == 0:
20922092
exit_with_error('Could not detect the launched browser subprocesses. The test harness will not be able to close the browser after testing is done, so aborting the test run here.')
20932093

0 commit comments

Comments
 (0)