Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: content/test/gpu/gpu_tests/context_lost.py

Issue 418733002: Prevent duplicate navigation to debug URLs from Telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Read crash count from Browser System Info instead of scrubbing chrome://gpu page. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os 4 import os
5 import time
5 6
6 from telemetry import benchmark as benchmark_module 7 from telemetry import benchmark as benchmark_module
7 from telemetry.core import exceptions 8 from telemetry.core import exceptions
8 from telemetry.core import util 9 from telemetry.core import util
9 from telemetry.page import page 10 from telemetry.page import page
10 from telemetry.page import page_set 11 from telemetry.page import page_set
11 from telemetry.page import page_test 12 from telemetry.page import page_test
12 13
13 data_path = os.path.join( 14 data_path = os.path.join(
14 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') 15 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu')
(...skipping 15 matching lines...) Expand all
30 domAutomationController._loaded = true; 31 domAutomationController._loaded = true;
31 } else if (msg == "success") { 32 } else if (msg == "success") {
32 domAutomationController._succeeded = true; 33 domAutomationController._succeeded = true;
33 domAutomationController._finished = true; 34 domAutomationController._finished = true;
34 } else { 35 } else {
35 domAutomationController._succeeded = false; 36 domAutomationController._succeeded = false;
36 domAutomationController._finished = true; 37 domAutomationController._finished = true;
37 } 38 }
38 } 39 }
39 40
41 domAutomationController.reset = function() {
42 domAutomationController._succeeded = false;
43 domAutomationController._finished = false;
44 }
45
40 window.domAutomationController = domAutomationController; 46 window.domAutomationController = domAutomationController;
41 console.log("Harness injected."); 47 console.log("Harness injected.");
42 """ 48 """
43 49
44 class _ContextLostValidator(page_test.PageTest): 50 class _ContextLostValidator(page_test.PageTest):
45 def __init__(self): 51 def __init__(self):
46 # Strictly speaking this test doesn't yet need a browser restart 52 # Strictly speaking this test doesn't yet need a browser restart
47 # after each run, but if more tests are added which crash the GPU 53 # after each run, but if more tests are added which crash the GPU
48 # process, then it will. 54 # process, then it will.
49 super(_ContextLostValidator, self).__init__( 55 super(_ContextLostValidator, self).__init__(
50 needs_browser_restart_after_each_page=True) 56 needs_browser_restart_after_each_page=True)
51 57
52 def CustomizeBrowserOptions(self, options): 58 def CustomizeBrowserOptions(self, options):
53 options.AppendExtraBrowserArgs( 59 options.AppendExtraBrowserArgs(
54 '--disable-domain-blocking-for-3d-apis') 60 '--disable-domain-blocking-for-3d-apis')
55 options.AppendExtraBrowserArgs( 61 options.AppendExtraBrowserArgs(
56 '--disable-gpu-process-crash-limit') 62 '--disable-gpu-process-crash-limit')
57 # Required for about:gpucrash handling from Telemetry. 63 # Required for about:gpucrash handling from Telemetry.
58 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') 64 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking')
59 65
60 def ValidatePage(self, page, tab, results): 66 def ValidatePage(self, page, tab, results):
61 if page.kill_gpu_process: 67 if page.kill_gpu_process:
62 # Doing the GPU process kill operation cooperatively -- in the 68 # Doing the GPU process kill operation cooperatively -- in the
63 # same page's context -- is much more stressful than restarting 69 # same page's context -- is much more stressful than restarting
64 # the browser every time. 70 # the browser every time.
65 for x in range(page.number_of_gpu_process_kills): 71 for x in range(page.number_of_gpu_process_kills):
66 if not tab.browser.supports_tab_control: 72 if not tab.browser.supports_tab_control:
67 raise page_test.Failure('Browser must support tab control') 73 raise page_test.Failure('Browser must support tab control')
74
75 expected_kills = x + 1
76
68 # Reset the test's state. 77 # Reset the test's state.
69 tab.EvaluateJavaScript( 78 tab.EvaluateJavaScript(
70 'window.domAutomationController._succeeded = false'); 79 'window.domAutomationController.reset()');
71 tab.EvaluateJavaScript(
72 'window.domAutomationController._finished = false');
73 # Crash the GPU process. 80 # Crash the GPU process.
74 new_tab = tab.browser.tabs.New() 81 gpucrash_tab = tab.browser.tabs.New()
75 # To access these debug URLs from Telemetry, they have to be 82 # To access these debug URLs from Telemetry, they have to be
76 # written using the chrome:// scheme. 83 # written using the chrome:// scheme.
77 # The try/except is a workaround for crbug.com/368107. 84 # The try/except is a workaround for crbug.com/368107.
78 try: 85 try:
79 new_tab.Navigate('chrome://gpucrash') 86 gpucrash_tab.Navigate('chrome://gpucrash')
80 except (exceptions.TabCrashException, Exception): 87 except (exceptions.TabCrashException, Exception):
81 print 'Tab crashed while navigating to chrome://gpucrash' 88 print 'Tab crashed while navigating to chrome://gpucrash'
82 # Activate the original tab and wait for completion. 89 # Activate the original tab and wait for completion.
83 tab.Activate() 90 tab.Activate()
84 completed = False 91 completed = False
85 try: 92 try:
86 util.WaitFor(lambda: tab.EvaluateJavaScript( 93 util.WaitFor(lambda: tab.EvaluateJavaScript(
87 'window.domAutomationController._finished'), wait_timeout) 94 'window.domAutomationController._finished'), wait_timeout)
88 completed = True 95 completed = True
89 except util.TimeoutException: 96 except util.TimeoutException:
90 pass 97 pass
98
99 if page.check_crash_count:
100 if not tab.browser.supports_system_info:
101 raise page_test.Failure('Browser must support system info')
102
103 number_of_crashes = -1
104 # To allow time for a gpucrash to complete, wait 10s with
105 # maximum retry x3 times.
106 for retry in range(3):
107 time.sleep(10)
108 system_info = tab.browser.GetSystemInfo()
109 number_of_crashes = \
110 system_info.gpu.aux_attributes[u'process_crash_count']
111 if number_of_crashes >= expected_kills:
112 break
113
114 if number_of_crashes < expected_kills:
115 raise page_test.Failure(
116 'Timed out waiting for a gpu process crash')
117 elif number_of_crashes != expected_kills:
118 raise page_test.Failure(
119 'Expected %d gpu process crashes; got: %d' %
120 (expected_kills, number_of_crashes))
121
91 # The try/except is a workaround for crbug.com/368107. 122 # The try/except is a workaround for crbug.com/368107.
92 try: 123 try:
93 new_tab.Close() 124 gpucrash_tab.Close()
94 except (exceptions.TabCrashException, Exception): 125 except (exceptions.TabCrashException, Exception):
95 print 'Tab crashed while closing chrome://gpucrash' 126 print 'Tab crashed while closing chrome://gpucrash'
96 if not completed: 127 if not completed:
97 raise page_test.Failure( 128 raise page_test.Failure(
98 'Test didn\'t complete (no context lost event?)') 129 'Test didn\'t complete (no context lost event?)')
99 if not tab.EvaluateJavaScript( 130 if not tab.EvaluateJavaScript(
100 'window.domAutomationController._succeeded'): 131 'window.domAutomationController._succeeded'):
101 raise page_test.Failure( 132 raise page_test.Failure(
102 'Test failed (context not restored properly?)') 133 'Test failed (context not restored properly?)')
103 elif page.force_garbage_collection: 134 elif page.force_garbage_collection:
(...skipping 26 matching lines...) Expand all
130 completed = True 161 completed = True
131 except util.TimeoutException: 162 except util.TimeoutException:
132 pass 163 pass
133 164
134 if not completed: 165 if not completed:
135 raise page_test.Failure('Test didn\'t complete') 166 raise page_test.Failure('Test didn\'t complete')
136 if not tab.EvaluateJavaScript( 167 if not tab.EvaluateJavaScript(
137 'window.domAutomationController._succeeded'): 168 'window.domAutomationController._succeeded'):
138 raise page_test.Failure('Test failed') 169 raise page_test.Failure('Test failed')
139 170
171 # Test that navigating to chrome://gpucrash causes the GPU process to crash
172 # exactly one time per navigation.
173 class GPUProcessCrashesExactlyOnce(page.Page):
174 def __init__(self, page_set, base_dir):
175 super(GPUProcessCrashesExactlyOnce, self).__init__(
176 url='file://gpu_process_crash.html',
177 page_set=page_set,
178 base_dir=base_dir,
179 name='GpuCrash.GPUProcessCrashesExactlyOnce')
180 self.script_to_evaluate_on_commit = harness_script
181 self.kill_gpu_process = True
182 self.number_of_gpu_process_kills = 2
183 self.check_crash_count = True
184 self.force_garbage_collection = False
185
186 def RunNavigateSteps(self, action_runner):
187 action_runner.NavigateToPage(self)
188 action_runner.WaitForJavaScriptCondition(
189 'window.domAutomationController._loaded')
190
140 class WebGLContextLostFromGPUProcessExitPage(page.Page): 191 class WebGLContextLostFromGPUProcessExitPage(page.Page):
141 def __init__(self, page_set, base_dir): 192 def __init__(self, page_set, base_dir):
142 super(WebGLContextLostFromGPUProcessExitPage, self).__init__( 193 super(WebGLContextLostFromGPUProcessExitPage, self).__init__(
143 url='file://webgl.html?query=kill_after_notification', 194 url='file://webgl.html?query=kill_after_notification',
144 page_set=page_set, 195 page_set=page_set,
145 base_dir=base_dir, 196 base_dir=base_dir,
146 name='ContextLost.WebGLContextLostFromGPUProcessExit') 197 name='ContextLost.WebGLContextLostFromGPUProcessExit')
147 self.script_to_evaluate_on_commit = harness_script 198 self.script_to_evaluate_on_commit = harness_script
148 self.kill_gpu_process = True 199 self.kill_gpu_process = True
200 self.check_crash_count = False
149 self.number_of_gpu_process_kills = 1 201 self.number_of_gpu_process_kills = 1
150 self.force_garbage_collection = False 202 self.force_garbage_collection = False
151 203
152 def RunNavigateSteps(self, action_runner): 204 def RunNavigateSteps(self, action_runner):
153 action_runner.NavigateToPage(self) 205 action_runner.NavigateToPage(self)
154 action_runner.WaitForJavaScriptCondition( 206 action_runner.WaitForJavaScriptCondition(
155 'window.domAutomationController._loaded') 207 'window.domAutomationController._loaded')
156 208
157 209
158 class WebGLContextLostFromLoseContextExtensionPage(page.Page): 210 class WebGLContextLostFromLoseContextExtensionPage(page.Page):
159 def __init__(self, page_set, base_dir): 211 def __init__(self, page_set, base_dir):
160 super(WebGLContextLostFromLoseContextExtensionPage, self).__init__( 212 super(WebGLContextLostFromLoseContextExtensionPage, self).__init__(
161 url='file://webgl.html?query=WEBGL_lose_context', 213 url='file://webgl.html?query=WEBGL_lose_context',
162 page_set=page_set, 214 page_set=page_set,
163 base_dir=base_dir, 215 base_dir=base_dir,
164 name='ContextLost.WebGLContextLostFromLoseContextExtension') 216 name='ContextLost.WebGLContextLostFromLoseContextExtension')
165 self.script_to_evaluate_on_commit = harness_script 217 self.script_to_evaluate_on_commit = harness_script
166 self.kill_gpu_process = False 218 self.kill_gpu_process = False
219 self.check_crash_count = False
167 self.force_garbage_collection = False 220 self.force_garbage_collection = False
168 221
169 def RunNavigateSteps(self, action_runner): 222 def RunNavigateSteps(self, action_runner):
170 action_runner.NavigateToPage(self) 223 action_runner.NavigateToPage(self)
171 action_runner.WaitForJavaScriptCondition( 224 action_runner.WaitForJavaScriptCondition(
172 'window.domAutomationController._finished') 225 'window.domAutomationController._finished')
173 226
174 class WebGLContextLostFromQuantityPage(page.Page): 227 class WebGLContextLostFromQuantityPage(page.Page):
175 def __init__(self, page_set, base_dir): 228 def __init__(self, page_set, base_dir):
176 super(WebGLContextLostFromQuantityPage, self).__init__( 229 super(WebGLContextLostFromQuantityPage, self).__init__(
177 url='file://webgl.html?query=forced_quantity_loss', 230 url='file://webgl.html?query=forced_quantity_loss',
178 page_set=page_set, 231 page_set=page_set,
179 base_dir=base_dir, 232 base_dir=base_dir,
180 name='ContextLost.WebGLContextLostFromQuantity') 233 name='ContextLost.WebGLContextLostFromQuantity')
181 self.script_to_evaluate_on_commit = harness_script 234 self.script_to_evaluate_on_commit = harness_script
182 self.kill_gpu_process = False 235 self.kill_gpu_process = False
236 self.check_crash_count = False
183 self.force_garbage_collection = True 237 self.force_garbage_collection = True
184 238
185 def RunNavigateSteps(self, action_runner): 239 def RunNavigateSteps(self, action_runner):
186 action_runner.NavigateToPage(self) 240 action_runner.NavigateToPage(self)
187 action_runner.WaitForJavaScriptCondition( 241 action_runner.WaitForJavaScriptCondition(
188 'window.domAutomationController._loaded') 242 'window.domAutomationController._loaded')
189 243
190 class WebGLContextLostFromSelectElementPage(page.Page): 244 class WebGLContextLostFromSelectElementPage(page.Page):
191 def __init__(self, page_set, base_dir): 245 def __init__(self, page_set, base_dir):
192 super(WebGLContextLostFromSelectElementPage, self).__init__( 246 super(WebGLContextLostFromSelectElementPage, self).__init__(
193 url='file://webgl_with_select_element.html', 247 url='file://webgl_with_select_element.html',
194 page_set=page_set, 248 page_set=page_set,
195 base_dir=base_dir, 249 base_dir=base_dir,
196 name='ContextLost.WebGLContextLostFromSelectElement') 250 name='ContextLost.WebGLContextLostFromSelectElement')
197 self.script_to_evaluate_on_commit = harness_script 251 self.script_to_evaluate_on_commit = harness_script
198 self.kill_gpu_process = False 252 self.kill_gpu_process = False
253 self.check_crash_count = False
199 self.force_garbage_collection = False 254 self.force_garbage_collection = False
200 255
201 def RunNavigateSteps(self, action_runner): 256 def RunNavigateSteps(self, action_runner):
202 action_runner.NavigateToPage(self) 257 action_runner.NavigateToPage(self)
203 action_runner.WaitForJavaScriptCondition( 258 action_runner.WaitForJavaScriptCondition(
204 'window.domAutomationController._loaded') 259 'window.domAutomationController._loaded')
205 260
206 class ContextLost(benchmark_module.Benchmark): 261 class ContextLost(benchmark_module.Benchmark):
207 enabled = True 262 enabled = True
208 test = _ContextLostValidator 263 test = _ContextLostValidator
209 # For the record, this would have been another way to get the pages 264 # For the record, this would have been another way to get the pages
210 # to repeat. pageset_repeat would be another option. 265 # to repeat. pageset_repeat would be another option.
211 # options = {'page_repeat': 5} 266 # options = {'page_repeat': 5}
212 def CreatePageSet(self, options): 267 def CreatePageSet(self, options):
213 ps = page_set.PageSet( 268 ps = page_set.PageSet(
214 file_path=data_path, 269 file_path=data_path,
215 user_agent_type='desktop', 270 user_agent_type='desktop',
216 serving_dirs=set([''])) 271 serving_dirs=set(['']))
272 ps.AddPage(GPUProcessCrashesExactlyOnce(ps, ps.base_dir))
217 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) 273 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir))
218 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir)) 274 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir))
219 ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir)) 275 ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir))
220 ps.AddPage(WebGLContextLostFromSelectElementPage(ps, ps.base_dir)) 276 ps.AddPage(WebGLContextLostFromSelectElementPage(ps, ps.base_dir))
221 return ps 277 return ps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698