Skip to content

Commit fcf14e5

Browse files
committed
Disable the NetworkService and use the newer method of setting trace configs
The NetworkService was enabled by default in Chrome 74 but currently breaks netlog trace events (at least in WebPageTest)
1 parent b76048f commit fcf14e5

3 files changed

Lines changed: 48 additions & 27 deletions

File tree

internal/chrome_android.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ def launch(self, job, task):
120120
args.append('--log-net-log=/data/local/tmp/netlog.txt')
121121
if 'overrideHosts' in task and task['overrideHosts']:
122122
args.append('--enable-features=NetworkService')
123+
else:
124+
args.append('--disable-features=NetworkService')
123125
command_line = 'chrome ' + ' '.join(args)
124126
if 'addCmdLine' in job:
125127
command_line += ' ' + job['addCmdLine']

internal/chrome_desktop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'--disable-background-networking',
1717
'--no-default-browser-check',
1818
'--no-first-run',
19-
'--process-per-tab',
2019
'--new-window',
2120
'--disable-infobars',
2221
'--disable-translate',
@@ -76,6 +75,8 @@ def launch(self, job, task):
7675
self.setup_prefs(task['profile'])
7776
if 'overrideHosts' in task and task['overrideHosts']:
7877
args.append('--enable-features=NetworkService')
78+
else:
79+
args.append('--disable-features=NetworkService')
7980
if self.options.xvfb:
8081
args.append('--disable-gpu')
8182
if self.options.dockerized:

internal/devtools.py

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -268,48 +268,66 @@ def start_recording(self):
268268
self.send_command('Profiler.enable', {})
269269
self.send_command('Profiler.setSamplingInterval', {'interval': 100})
270270
self.send_command('Profiler.start', {})
271+
trace_config = {"recordMode": "recordAsMuchAsPossible",
272+
"includedCategories": []}
271273
if 'trace' in self.job and self.job['trace']:
272274
if 'traceCategories' in self.job:
273-
trace = self.job['traceCategories']
274-
if not trace.startswith('-*,'):
275-
trace = '-*,' + trace
276-
if trace.find('netlog') >= 0:
275+
categories = self.job['traceCategories'].split(',')
276+
for category in categories:
277+
if category.find("*") < 0 and category not in trace_config["includedCategories"]:
278+
trace_config["includedCategories"].append(category)
279+
if "netlog" in trace_config["includedCategories"]:
277280
self.job['keep_netlog'] = True
278281
else:
279-
trace = "-*,toplevel,blink,v8,cc,gpu,blink.net," \
280-
"disabled-by-default-v8.runtime_stats"
282+
trace_config["includedCategories"] = [
283+
"toplevel",
284+
"blink",
285+
"v8",
286+
"cc",
287+
"gpu",
288+
"blink.net",
289+
"disabled-by-default-v8.runtime_stats"
290+
]
281291
self.job['keep_netlog'] = True
282292
else:
283293
self.job['keep_netlog'] = False
284-
trace = "-*"
285294
if 'netlog' in self.job and self.job['netlog']:
286295
self.job['keep_netlog'] = True
287296
if 'timeline' in self.job and self.job['timeline']:
288-
trace += ',' + ','.join([
289-
'blink.console',
290-
'devtools.timeline'
291-
])
297+
if "blink.console" not in trace_config["includedCategories"]:
298+
trace_config["includedCategories"].append("blink.console")
299+
if "devtools.timeline" not in trace_config["includedCategories"]:
300+
trace_config["includedCategories"].append("devtools.timeline")
301+
trace_config["enableSampling"] = True
292302
if 'timeline_fps' in self.job and self.job['timeline_fps']:
293-
trace += ',' + ','.join([
294-
'disabled-by-default-devtools.timeline',
295-
'disabled-by-default-devtools.timeline.frame'
296-
])
303+
if "disabled-by-default-devtools.timeline" not in trace_config["includedCategories"]:
304+
trace_config["includedCategories"].append("disabled-by-default-devtools.timeline")
305+
if "disabled-by-default-devtools.timeline.frame" not in trace_config["includedCategories"]:
306+
trace_config["includedCategories"].append("disabled-by-default-devtools.timeline.frame")
297307
if self.use_devtools_video and self.job['video']:
298-
trace += ",disabled-by-default-devtools.screenshot"
308+
if "disabled-by-default-devtools.screenshot" not in trace_config["includedCategories"]:
309+
trace_config["includedCategories"].append("disabled-by-default-devtools.screenshot")
299310
self.recording_video = True
300311
# Add the required trace events
301-
if trace.find(',rail') == -1:
302-
trace += ',rail'
303-
if trace.find(',blink.user_timing') == -1:
304-
trace += ',blink.user_timing'
305-
if trace.find(',netlog') == -1:
306-
trace += ',netlog'
307-
if trace.find(',disabled-by-default-blink.feature_usage') == -1:
308-
trace += ',disabled-by-default-blink.feature_usage'
312+
if "rail" not in trace_config["includedCategories"]:
313+
trace_config["includedCategories"].append("rail")
314+
if "blink.user_timing" not in trace_config["includedCategories"]:
315+
trace_config["includedCategories"].append("blink.user_timing")
316+
if "netlog" not in trace_config["includedCategories"]:
317+
trace_config["includedCategories"].append("netlog")
318+
if "net" not in trace_config["includedCategories"]:
319+
trace_config["includedCategories"].append("net")
320+
if "disabled-by-default-netlog" not in trace_config["includedCategories"]:
321+
trace_config["includedCategories"].append("disabled-by-default-netlog")
322+
if "disabled-by-default-net" not in trace_config["includedCategories"]:
323+
trace_config["includedCategories"].append("disabled-by-default-net")
324+
if "disabled-by-default-network" not in trace_config["includedCategories"]:
325+
trace_config["includedCategories"].append("disabled-by-default-network")
326+
if "disabled-by-default-blink.feature_usage" not in trace_config["includedCategories"]:
327+
trace_config["includedCategories"].append("disabled-by-default-blink.feature_usage")
309328
self.trace_enabled = True
310329
self.send_command('Tracing.start',
311-
{'categories': trace,
312-
'options': 'record-as-much-as-possible'},
330+
{'traceConfig': trace_config},
313331
wait=True)
314332
now = monotonic.monotonic()
315333
if not self.task['stop_at_onload']:

0 commit comments

Comments
 (0)