Bug 493601 Fix crash involving Flash module unloading. Patch by jmathies, r=emaijala,joshmoz,bent sr=brendan, a=dveditz
git-svn-id: svn://10.0.0.236/trunk@257578 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -63,6 +63,9 @@
|
||||
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID); // needed for NS_TRY_SAFE_CALL
|
||||
|
||||
#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION "MozillaPluginWindowPropertyAssociation"
|
||||
#define NS_PLUGIN_CUSTOM_MSG_ID TEXT("MozFlashUserRelay")
|
||||
#define WM_USER_FLASH WM_USER+1
|
||||
static UINT sWM_FLASHBOUNCEMSG = 0;
|
||||
|
||||
typedef nsTWeakRef<class nsPluginNativeWindowWin> PluginWindowWeakRef;
|
||||
|
||||
@@ -162,12 +165,21 @@ public:
|
||||
static PRBool sInMessageDispatch = PR_FALSE;
|
||||
static UINT sLastMsg = 0;
|
||||
|
||||
static PRBool ProcessFlashMessageDelayed(nsPluginNativeWindowWin * aWin,
|
||||
static PRBool ProcessFlashMessageDelayed(nsPluginNativeWindowWin * aWin, nsIPluginInstance * aInst,
|
||||
HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
NS_ENSURE_TRUE(aWin, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(aInst, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (msg != WM_USER+1)
|
||||
if (msg == sWM_FLASHBOUNCEMSG) {
|
||||
// See PluginWindowEvent::Run() below.
|
||||
NS_ASSERTION((sWM_FLASHBOUNCEMSG != 0), "RegisterWindowMessage failed in flash plugin WM_USER message handling!");
|
||||
NS_TRY_SAFE_CALL_VOID(::CallWindowProc((WNDPROC)aWin->GetWindowProc(), hWnd, WM_USER_FLASH, wParam, lParam),
|
||||
nsnull, aInst);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (msg != WM_USER_FLASH)
|
||||
return PR_FALSE; // no need to delay
|
||||
|
||||
// do stuff
|
||||
@@ -334,7 +346,7 @@ static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
|
||||
// (WM_USER+1) causing 100% CPU consumption and GUI freeze, see mozilla bug 132759;
|
||||
// we can prevent this from happening by delaying the processing such messages;
|
||||
if (win->mPluginType == nsPluginType_Flash) {
|
||||
if (ProcessFlashMessageDelayed(win, hWnd, msg, wParam, lParam))
|
||||
if (ProcessFlashMessageDelayed(win, inst, hWnd, msg, wParam, lParam))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -401,6 +413,10 @@ nsPluginNativeWindowWin::nsPluginNativeWindowWin() : nsPluginNativeWindow()
|
||||
mPrevWinProc = NULL;
|
||||
mPluginWinProc = NULL;
|
||||
mPluginType = nsPluginType_Unknown;
|
||||
|
||||
if (sWM_FLASHBOUNCEMSG == 0)
|
||||
sWM_FLASHBOUNCEMSG = ::RegisterWindowMessage(NS_PLUGIN_CUSTOM_MSG_ID);
|
||||
|
||||
}
|
||||
|
||||
nsPluginNativeWindowWin::~nsPluginNativeWindowWin()
|
||||
@@ -432,12 +448,23 @@ NS_IMETHODIMP PluginWindowEvent::Run()
|
||||
|
||||
nsCOMPtr<nsIPluginInstance> inst;
|
||||
win->GetPluginInstance(inst);
|
||||
NS_TRY_SAFE_CALL_VOID(::CallWindowProc(win->GetWindowProc(),
|
||||
hWnd,
|
||||
GetMsg(),
|
||||
GetWParam(),
|
||||
GetLParam()),
|
||||
nsnull, inst);
|
||||
|
||||
if (GetMsg() == WM_USER_FLASH) {
|
||||
// XXX Unwind issues related to runnable event callback depth for this
|
||||
// event and destruction of the plugin. (Bug 493601)
|
||||
::PostMessage(hWnd, sWM_FLASHBOUNCEMSG, GetWParam(), GetLParam());
|
||||
}
|
||||
else {
|
||||
// Currently not used, but added so that processing events here
|
||||
// is more generic.
|
||||
NS_TRY_SAFE_CALL_VOID(::CallWindowProc(win->GetWindowProc(),
|
||||
hWnd,
|
||||
GetMsg(),
|
||||
GetWParam(),
|
||||
GetLParam()),
|
||||
nsnull, inst);
|
||||
}
|
||||
|
||||
Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user