Bug 1179972 - Avoid send message hangs via WM_CHILDACTIVATE in PluginInstanceChild. r=aklotz, a=kglazko
authorJim Mathies <jmathies@mozilla.com>
Mon, 06 Jul 2015 12:39:25 -0500
changeset 281465 643f2b026cbab62d7defc423ed699217fef538b0
parent 281464 5bea001f678065581444c4e643aad4dea2b036a8
child 281466 69c605d160431eeddbea94ad691e5ee51810422f
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz, kglazko
bugs1179972
milestone41.0a2
Bug 1179972 - Avoid send message hangs via WM_CHILDACTIVATE in PluginInstanceChild. r=aklotz, a=kglazko
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginWidgetParent.cpp
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -1496,32 +1496,35 @@ PluginInstanceChild::PluginWindowProcInt
         pos->x = pos->y = 0;
         pos->cx = self->mPluginSize.x;
         pos->cy = self->mPluginSize.y;
         return res;
       }
     }
 
     // The plugin received keyboard focus, let the parent know so the dom is up to date.
-    if (message == WM_MOUSEACTIVATE)
+    if (message == WM_MOUSEACTIVATE) {
       self->CallPluginFocusChange(true);
+    }
 
     // Prevent lockups due to plugins making rpc calls when the parent
     // is making a synchronous SendMessage call to the child window. Add
     // more messages as needed.
     if ((InSendMessageEx(nullptr)&(ISMEX_REPLIED|ISMEX_SEND)) == ISMEX_SEND) {
         switch(message) {
+            case WM_CHILDACTIVATE:
             case WM_KILLFOCUS:
             ReplyMessage(0);
             break;
         }
     }
 
-    if (message == WM_KILLFOCUS)
+    if (message == WM_KILLFOCUS) {
       self->CallPluginFocusChange(false);
+    }
 
     if (message == WM_USER+1 &&
         (self->GetQuirks() & PluginModuleChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)) {
         self->FlashThrottleMessage(hWnd, message, wParam, lParam, true);
         return 0;
     }
 
     NS_ASSERTION(self->mPluginWndProc != PluginWindowProc,
@@ -1542,21 +1545,23 @@ PluginInstanceChild::PluginWindowProcInt
       if (hwnd && GetClassNameW(hwnd, szClass,
                                 sizeof(szClass)/sizeof(char16_t)) &&
           !wcscmp(szClass, kFlashFullscreenClass)) {
         ReleaseCapture();
         SetFocus(hwnd);
       }
     }
 
-    if (message == WM_CLOSE)
+    if (message == WM_CLOSE) {
         self->DestroyPluginWindow();
-
-    if (message == WM_NCDESTROY)
+    }
+
+    if (message == WM_NCDESTROY) {
         RemoveProp(hWnd, kPluginInstanceChildProperty);
+    }
 
     return res;
 }
 
 /* set window long ptr hook for flash */
 
 /*
  * Flash will reset the subclass of our widget at various times.
--- a/dom/plugins/ipc/PluginWidgetParent.cpp
+++ b/dom/plugins/ipc/PluginWidgetParent.cpp
@@ -65,16 +65,19 @@ mozilla::dom::TabParent*
 PluginWidgetParent::GetTabParent()
 {
   return static_cast<mozilla::dom::TabParent*>(Manager());
 }
 
 void
 PluginWidgetParent::SetParent(nsIWidget* aParent)
 {
+  // This will trigger sync send messages to the plugin process window
+  // procedure and a cascade of events to that window related to focus
+  // and activation.
   if (mWidget && aParent) {
     mWidget->SetParent(aParent);
   }
 }
 
 // When plugins run in chrome, nsPluginNativeWindow(Plat) implements platform
 // specific functionality that wraps plugin widgets. With e10s we currently
 // bypass this code on Window, and reuse a bit of it on Linux. Content still
@@ -211,17 +214,17 @@ PluginWidgetParent::RecvGetNativePluginP
 }
 
 bool
 PluginWidgetParent::RecvSetNativeChildWindow(const uintptr_t& aChildWindow)
 {
 #if defined(XP_WIN)
   ENSURE_CHANNEL;
   PWLOG("PluginWidgetParent::RecvSetNativeChildWindow(%p)\n",
-        static_cast<void*>(aChildWindow));
+        (void*)aChildWindow);
   mWidget->SetNativeData(NS_NATIVE_CHILD_WINDOW, aChildWindow);
   return true;
 #else
   NS_NOTREACHED("PluginWidgetParent::RecvSetNativeChildWindow not implemented!");
   return false;
 #endif
 }