fix hang on page with five or more Flash objects. patch by Steven Michaud. r=josh r=mento sr=pav
fix hang on page with five or more Flash objects. patch by Steven Michaud. r=josh r=mento sr=pav
--- a/widget/src/cocoa/nsAppShell.h
+++ b/widget/src/cocoa/nsAppShell.h
@@ -76,11 +76,12 @@ protected:
NSAutoreleasePool* mMainPool;
CFMutableArrayRef mAutoreleasePools;
NSPort* mPort;
AppShellDelegate* mDelegate;
PRPackedBool mRunningEventLoop;
PRPackedBool mTerminated;
+ PRPackedBool mSkippedNativeCallback;
};
#endif // nsAppShell_h_
--- a/widget/src/cocoa/nsAppShell.mm
+++ b/widget/src/cocoa/nsAppShell.mm
@@ -69,27 +69,32 @@
@end
// nsAppShell implementation
NS_IMETHODIMP
nsAppShell::ResumeNative(void)
{
nsresult retval = nsBaseAppShell::ResumeNative();
- if (NS_SUCCEEDED(retval) && (mSuspendNativeCount == 0))
+ if (NS_SUCCEEDED(retval) && (mSuspendNativeCount == 0) &&
+ mSkippedNativeCallback)
+ {
+ mSkippedNativeCallback = PR_FALSE;
ScheduleNativeEventCallback();
+ }
return retval;
}
nsAppShell::nsAppShell()
: mAutoreleasePools(nsnull)
, mPort(nil)
, mDelegate(nil)
, mRunningEventLoop(PR_FALSE)
, mTerminated(PR_FALSE)
+, mSkippedNativeCallback(PR_FALSE)
{
// mMainPool sits low on the autorelease pool stack to serve as a catch-all
// for autoreleased objects on this thread. Because it won't be popped
// until the appshell is destroyed, objects attached to this pool will
// be leaked until app shutdown. You probably don't want this!
//
// Objects autoreleased to this pool may result in warnings in the future.
mMainPool = [[NSAutoreleasePool alloc] init];
@@ -199,18 +204,21 @@ nsAppShell::ProcessGeckoEvents()
windowNumber:-1
context:NULL
subtype:0
data1:0
data2:0]
atStart:NO];
}
- if (mSuspendNativeCount <= 0)
+ if (mSuspendNativeCount <= 0) {
NativeEventCallback();
+ } else {
+ mSkippedNativeCallback = PR_TRUE;
+ }
[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
location:NSMakePoint(0,0)
modifierFlags:0
timestamp:0
windowNumber:-1
context:NULL
subtype:0
--- a/widget/src/mac/nsAppShell.cpp
+++ b/widget/src/mac/nsAppShell.cpp
@@ -55,25 +55,30 @@ enum {
};
// nsAppShell implementation
NS_IMETHODIMP
nsAppShell::ResumeNative(void)
{
nsresult retval = nsBaseAppShell::ResumeNative();
- if (NS_SUCCEEDED(retval) && (mSuspendNativeCount == 0))
+ if (NS_SUCCEEDED(retval) && (mSuspendNativeCount == 0) &&
+ mSkippedNativeCallback)
+ {
+ mSkippedNativeCallback = PR_FALSE;
ScheduleNativeEventCallback();
+ }
return retval;
}
nsAppShell::nsAppShell()
: mCFRunLoop(NULL)
, mCFRunLoopSource(NULL)
, mRunningEventLoop(PR_FALSE)
+, mSkippedNativeCallback(PR_FALSE)
{
}
nsAppShell::~nsAppShell()
{
if (mCFRunLoopSource) {
::CFRunLoopRemoveSource(mCFRunLoop, mCFRunLoopSource,
kCFRunLoopCommonModes);
@@ -204,13 +209,16 @@ nsAppShell::ProcessGeckoEvents(void* aIn
kEventAttributeNone, &bogusEvent);
if (err == noErr) {
::PostEventToQueue(::GetMainEventQueue(), bogusEvent,
kEventPriorityStandard);
::ReleaseEvent(bogusEvent);
}
}
- if (self->mSuspendNativeCount <= 0)
- self->NativeEventCallback();
+ if (mSuspendNativeCount <= 0) {
+ NativeEventCallback();
+ } else {
+ mSkippedNativeCallback = PR_TRUE;
+ }
NS_RELEASE(self);
}
--- a/widget/src/mac/nsAppShell.h
+++ b/widget/src/mac/nsAppShell.h
@@ -74,11 +74,12 @@ protected:
protected:
nsCOMPtr<nsIToolkit> mToolkit;
nsAutoPtr<nsMacMessagePump> mMacPump;
CFRunLoopRef mCFRunLoop;
CFRunLoopSourceRef mCFRunLoopSource;
PRBool mRunningEventLoop;
+ PRBool mSkippedNativeCallback;
};
#endif // nsAppShell_h__