Commit 5eab9931 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

DevTools: Try to fix flaky test heap-objects-tracking

This test registered a callback that was an async function, but the
caller doesn't await the result. This means that we re-entered the
callback and modified the global counter, which was not expected.

Update the test to de-register the callback before awaiting the
stopTracking call, even though we still have an async function
where it doesn't belong, this could at least stop the flakiness.

Bug: 824904
Change-Id: Ib32eabdefb409f082dcb1f99db5f1d527fff88fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986080
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728196}
parent 4071913c
...@@ -4903,7 +4903,6 @@ crbug.com/824775 [ Mac ] virtual/audio-service/media/controls/video-controls-wit ...@@ -4903,7 +4903,6 @@ crbug.com/824775 [ Mac ] virtual/audio-service/media/controls/video-controls-wit
crbug.com/824848 [ Linux ] external/wpt/html/semantics/links/following-hyperlinks/activation-behavior.window.html [ Pass Failure ] crbug.com/824848 [ Linux ] external/wpt/html/semantics/links/following-hyperlinks/activation-behavior.window.html [ Pass Failure ]
crbug.com/824848 [ Mac ] external/wpt/html/semantics/links/following-hyperlinks/activation-behavior.window.html [ Pass Failure ] crbug.com/824848 [ Mac ] external/wpt/html/semantics/links/following-hyperlinks/activation-behavior.window.html [ Pass Failure ]
crbug.com/824848 [ Win ] external/wpt/html/semantics/links/following-hyperlinks/activation-behavior.window.html [ Pass Failure ] crbug.com/824848 [ Win ] external/wpt/html/semantics/links/following-hyperlinks/activation-behavior.window.html [ Pass Failure ]
crbug.com/824904 inspector-protocol/heap-profiler/heap-objects-tracking.js [ Pass Failure ]
# Sheriff 2018-03-26 # Sheriff 2018-03-26
crbug.com/825733 [ Win ] media/color-profile-video-seek-filter.html [ Pass Timeout Failure ] crbug.com/825733 [ Win ] media/color-profile-video-seek-filter.html [ Pass Timeout Failure ]
......
...@@ -26,7 +26,7 @@ HeapProfiler.lastSeenObjectId has params.lastSeenObjectId: true ...@@ -26,7 +26,7 @@ HeapProfiler.lastSeenObjectId has params.lastSeenObjectId: true
HeapProfiler.lastSeenObjectId has timestamp: true HeapProfiler.lastSeenObjectId has timestamp: true
A heap stats fragment did arrive before HeapProfiler.lastSeenObjectId: true A heap stats fragment did arrive before HeapProfiler.lastSeenObjectId: true
Number of heapStatsUpdate events >= numbrt of lastSeenObjectId events: true Number of heapStatsUpdate events >= number of lastSeenObjectId events: true
At least 2 lastSeenObjectId arrived: true At least 2 lastSeenObjectId arrived: true
SUCCESS: tracking stopped SUCCESS: tracking stopped
(async function(testRunner) { (async function(testRunner) {
var {page, session, dp} = await testRunner.startBlank('Test that heap tracking actually reports data fragments.'); const {page, session, dp} = await testRunner.startBlank('Test that heap tracking actually reports data fragments.');
await session.evaluate(` await session.evaluate(`
var junkArray = new Array(1000); const junkArray = new Array(1000);
function junkGenerator() { function junkGenerator() {
for (var i = 0; i < junkArray.length; ++i) for (let i = 0; i < junkArray.length; ++i)
junkArray[i] = '42 ' + i; junkArray[i] = '42 ' + i;
window.junkArray = junkArray; window.junkArray = junkArray;
} }
setInterval(junkGenerator, 0) setInterval(junkGenerator, 0)
`); `);
var lastSeenObjectIdEventCount = 0; let lastSeenObjectIdEventCount = 0;
var heapStatsUpdateEventCount = 0; let heapStatsUpdateEventCount = 0;
var fragments = []; let fragments = [];
dp.HeapProfiler.onLastSeenObjectId(async messageObject => { const objectIdCallback = async messageObject => {
++lastSeenObjectIdEventCount; ++lastSeenObjectIdEventCount;
if (lastSeenObjectIdEventCount <= 2) { if (lastSeenObjectIdEventCount <= 2) {
var params = messageObject['params']; const params = messageObject['params'];
testRunner.log('HeapProfiler.lastSeenObjectId has params: ' + !!params); testRunner.log('HeapProfiler.lastSeenObjectId has params: ' + !!params);
testRunner.log('HeapProfiler.lastSeenObjectId has params.lastSeenObjectId: ' + !!params.lastSeenObjectId); testRunner.log('HeapProfiler.lastSeenObjectId has params.lastSeenObjectId: ' + !!params.lastSeenObjectId);
testRunner.log('HeapProfiler.lastSeenObjectId has timestamp: ' + !!params.timestamp); testRunner.log('HeapProfiler.lastSeenObjectId has timestamp: ' + !!params.timestamp);
...@@ -26,21 +26,28 @@ ...@@ -26,21 +26,28 @@
testRunner.log(''); testRunner.log('');
} }
if (lastSeenObjectIdEventCount === 2) { if (lastSeenObjectIdEventCount === 2) {
// Wait for two updates and then stop tracing. // Wait for two updates and then stop tracing. Turn off these callbacks.
// This callback is not awaited by the caller, meaning we can re-enter
// this callback while awaiting the below call. This would cause the count
// to get incremented again. We avoid this by de-registering the callback.
dp.HeapProfiler.offLastSeenObjectId(objectIdCallback);
await dp.HeapProfiler.stopTrackingHeapObjects(); await dp.HeapProfiler.stopTrackingHeapObjects();
testRunner.log('Number of heapStatsUpdate events >= numbrt of lastSeenObjectId events: ' + (heapStatsUpdateEventCount >= lastSeenObjectIdEventCount)); testRunner.log('Number of heapStatsUpdate events >= number of lastSeenObjectId events: ' + (heapStatsUpdateEventCount >= lastSeenObjectIdEventCount));
testRunner.log('At least 2 lastSeenObjectId arrived: ' + (lastSeenObjectIdEventCount >= 2)); testRunner.log('At least 2 lastSeenObjectId arrived: ' + (lastSeenObjectIdEventCount >= 2));
testRunner.log('SUCCESS: tracking stopped'); testRunner.log('SUCCESS: tracking stopped');
testRunner.completeTest(); testRunner.completeTest();
} }
}); };
dp.HeapProfiler.onLastSeenObjectId(objectIdCallback);
dp.HeapProfiler.onHeapStatsUpdate(messageObject => { dp.HeapProfiler.onHeapStatsUpdate(messageObject => {
++heapStatsUpdateEventCount; ++heapStatsUpdateEventCount;
var params = messageObject['params']; const params = messageObject['params'];
if (heapStatsUpdateEventCount <= 2) if (heapStatsUpdateEventCount <= 2) {
testRunner.log('HeapProfiler.heapStatsUpdate has params: ' + !!params); testRunner.log('HeapProfiler.heapStatsUpdate has params: ' + !!params);
var statsUpdate = params.statsUpdate; }
const statsUpdate = params.statsUpdate;
if (heapStatsUpdateEventCount <= 2) { if (heapStatsUpdateEventCount <= 2) {
testRunner.log('HeapProfiler.heapStatsUpdate has statsUpdate: ' + !!statsUpdate); testRunner.log('HeapProfiler.heapStatsUpdate has statsUpdate: ' + !!statsUpdate);
testRunner.log('statsUpdate length is not zero: ' + !!statsUpdate.length); testRunner.log('statsUpdate length is not zero: ' + !!statsUpdate.length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment