Skip to content

Instantly share code, notes, and snippets.

@adngdb
Created February 25, 2015 14:12
Show Gist options
  • Save adngdb/c05a8f7bd13fec9b7701 to your computer and use it in GitHub Desktop.
Save adngdb/c05a8f7bd13fec9b7701 to your computer and use it in GitHub Desktop.
Classify crashes running DXVA
import datetime
import os
import requests
def look_for_module(dump, module, count_mode=False):
count = 0
for thread in dump['threads']:
for frame in thread['frames']:
if 'module' not in frame:
continue
if module == frame['module']:
if count_mode:
count += 1
# We only want to count the number of threads,
# not the number of frames, containing the module.
break
else:
return True
return count
def run():
two_weeks_ago = datetime.datetime.utcnow() - datetime.timedelta(days=14)
token = os.environ.get('API_TOKEN')
if not token:
print 'Error: an API Token is required.'
print 'Usage: API_TOKEN=xxxx python dvxa.py'
return
url = 'https://crash-stats.mozilla.com/api/SuperSearchUnredacted/'
params = {
'product': 'Firefox',
'version': '36.0',
'date': '>%s' % two_weeks_ago.isoformat(),
'_results_number': 100,
}
headers = {
'Auth-Token': token,
}
signatures = (
'moz_abort | pages_commit',
'D2DDeviceContextBase<ID2D1DeviceContext1, ID2D1DeviceContext1, ' \
'null_type>::FillRectangle(D2D_RECT_F const*, ID2D1Brush*)',
'DrawingContext::FillRectangle(D2D_RECT_F const*, ID2D1Brush*)',
)
max_number_of_results = 500
for sig in signatures:
params['signature'] = '=' + sig
hits = []
for i in range(0, max_number_of_results, 100):
params['_results_offset'] = i
r = requests.get(url, params=params, headers=headers, timeout=240)
assert r.status_code == 200, (r.status_code, r.text)
content = r.json()
hits.extend(content['hits'])
results = {
'invalid': [],
'no video': [],
'DXVA on': [],
'DXVA off': [],
}
for hit in hits:
dump = hit['json_dump']
if 'threads' not in dump:
# Invalid crash :(
classification['invalid'].append(hit['uuid'])
continue
# Look for the 'msmpeg2vdec.dll' module.
# If not found => video not playing.
video_playing = look_for_module(dump, 'msmpeg2vdec.dll')
if not video_playing:
classification = 'no video'
elif 'D3D9Layers' in hit['app_notes']:
count = look_for_module(dump, 'd3d9.dll', True)
if count > 1:
classification = 'DXVA on'
else:
classification = 'DXVA off'
else:
count = look_for_module(dump, 'd3d9.dll', True)
if count >= 1:
classification = 'DXVA on'
else:
classification = 'DXVA off'
results[classification].append(hit['uuid'])
# Nicely showing the results.
title = '%s (%s / %s)' % (sig, max_number_of_results, content['total'])
print title
print '-' * len(title)
print ''
for key, val in results.items():
print key, '\t', len(val)
print ''
if __name__ == '__main__':
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment