Bug 1558117 Part 2: Check if other side is closed while state is AboutToWait. r=jrmuizel
authorBob Owen <bobowencode@gmail.com>
Mon, 24 Feb 2020 10:53:43 +0000
changeset 515244 d2a8ac40ce6b0af1615fe81a36cb605d9c1f0e78
parent 515243 3b8384aee07a3afe3417572bc5cca959465895b8
child 515245 988672936c1bc88647ca7fa88b35e26d71de7f8f
push id37154
push usercsabou@mozilla.com
push dateMon, 24 Feb 2020 16:27:17 +0000
treeherdermozilla-central@8c5f9b08938e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1558117
milestone75.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 1558117 Part 2: Check if other side is closed while state is AboutToWait. r=jrmuizel If the other side crashed with AboutToWait set in CanvasEventRingBuffer then in theory we could spin forever waiting for it to change. Differential Revision: https://phabricator.services.mozilla.com/D61828
gfx/layers/CanvasDrawEventRecorder.cpp
--- a/gfx/layers/CanvasDrawEventRecorder.cpp
+++ b/gfx/layers/CanvasDrawEventRecorder.cpp
@@ -227,17 +227,21 @@ void CanvasEventRingBuffer::UpdateReadTo
 
 void CanvasEventRingBuffer::CheckAndSignalReader() {
   do {
     switch (mRead->state) {
       case State::Processing:
         return;
       case State::AboutToWait:
         // The reader is making a decision about whether to wait. So, we must
-        // wait until it has decided to avoid races.
+        // wait until it has decided to avoid races. Check if the reader is
+        // closed to avoid hangs.
+        if (mWriterServices->ReaderClosed()) {
+          return;
+        }
         continue;
       case State::Waiting:
         if (mRead->count != mOurCount) {
           // We have to use compareExchange here because the reader can change
           // from Waiting to Stopped.
           if (mRead->state.compareExchange(State::Waiting, State::Processing)) {
             mReaderSemaphore->Signal();
             return;
@@ -342,17 +346,21 @@ bool CanvasEventRingBuffer::WaitForCheck
 
 void CanvasEventRingBuffer::CheckAndSignalWriter() {
   do {
     switch (mWrite->state) {
       case State::Processing:
         return;
       case State::AboutToWait:
         // The writer is making a decision about whether to wait. So, we must
-        // wait until it has decided to avoid races.
+        // wait until it has decided to avoid races. Check if the writer is
+        // closed to avoid hangs.
+        if (mReaderServices->WriterClosed()) {
+          return;
+        }
         continue;
       case State::Waiting:
         if (mWrite->count - mOurCount <= mWrite->requiredDifference) {
           mWrite->state = State::Processing;
           mWriterSemaphore->Signal();
         }
         return;
       default: