Bug 1331854 - Spin the event loop instead blocking in RemoteInputStream::ReallyBlockAndWaitForStream, r=bkelly
☠☠ backed out by 8c38fdf34cef ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 20 Jan 2017 08:26:14 +0100
changeset 377562 25c65ac95fc5191ded02ade757f0a3da819266b0
parent 377561 4ec5bc4fff15bf293a7118065df335847d0e2f96
child 377563 7f69f35b4f62db4d3c659103c817c7e9f814d108
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1331854
milestone53.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 1331854 - Spin the event loop instead blocking in RemoteInputStream::ReallyBlockAndWaitForStream, r=bkelly
dom/file/ipc/Blob.cpp
--- a/dom/file/ipc/Blob.cpp
+++ b/dom/file/ipc/Blob.cpp
@@ -1010,22 +1010,30 @@ void
 RemoteInputStream::ReallyBlockAndWaitForStream()
 {
   MOZ_ASSERT(!IsOnOwningThread());
 
   DebugOnly<bool> waited;
 
   {
     MonitorAutoLock lock(mMonitor);
-
     waited = !mStream;
-
-    while (!mStream) {
-      mMonitor.Wait();
+  }
+
+  nsIThread* currentThread = NS_GetCurrentThread();
+  MOZ_ASSERT(currentThread);
+
+  while (true) {
+    {
+      MonitorAutoLock lock(mMonitor);
+      if (mStream) {
+        break;
+      }
     }
+    MOZ_ALWAYS_TRUE(NS_ProcessNextEvent(currentThread));
   }
 
   MOZ_ASSERT(mStream);
 
 #ifdef DEBUG
   if (waited && mWeakSeekableStream) {
     int64_t position;
     if (NS_SUCCEEDED(mWeakSeekableStream->Tell(&position))) {