Bug 1585073: In CanvasEventRingBuffer, check stream is good before waiting for space or data. r=jrmuizel
authorBob Owen <bobowencode@gmail.com>
Thu, 31 Oct 2019 13:44:32 +0000
changeset 500026 b79b68ee36fcacc1d8408c5a1b988c81e7b2d936
parent 500025 6d52b0976c8ef353249f1f71e2d3d7bbfeb55ada
child 500027 cfb65a5e10c0a1c1c08437be67bc5bc9fd83e29c
push id36752
push usershindli@mozilla.com
push dateFri, 01 Nov 2019 03:54:57 +0000
treeherdermozilla-central@0e1726e95801 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1585073
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1585073: In CanvasEventRingBuffer, check stream is good before waiting for space or data. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D51116
gfx/layers/CanvasDrawEventRecorder.cpp
--- a/gfx/layers/CanvasDrawEventRecorder.cpp
+++ b/gfx/layers/CanvasDrawEventRecorder.cpp
@@ -99,16 +99,20 @@ bool CanvasEventRingBuffer::InitReader(
 
   mReaderServices = std::move(aReaderServices);
 
   mGood = true;
   return true;
 }
 
 bool CanvasEventRingBuffer::WaitForAndRecalculateAvailableSpace() {
+  if (!good()) {
+    return false;
+  }
+
   uint32_t bufPos = mOurCount % kStreamSize;
   uint32_t maxToWrite = kStreamSize - bufPos;
   mAvailable = std::min(maxToWrite, WaitForBytesToWrite());
   if (!mAvailable) {
     mGood = false;
     mBufPos = nullptr;
     return false;
   }
@@ -156,16 +160,20 @@ void CanvasEventRingBuffer::IncrementWri
 
 void CanvasEventRingBuffer::UpdateWriteTotalsBy(uint32_t aCount) {
   IncrementWriteCountBy(aCount);
   mBufPos += aCount;
   mAvailable -= aCount;
 }
 
 bool CanvasEventRingBuffer::WaitForAndRecalculateAvailableData() {
+  if (!good()) {
+    return false;
+  }
+
   uint32_t bufPos = mOurCount % kStreamSize;
   uint32_t maxToRead = kStreamSize - bufPos;
   mAvailable = std::min(maxToRead, WaitForBytesToRead());
   if (!mAvailable) {
     mGood = false;
     mBufPos = nullptr;
     return false;
   }