Commit b26bd0ed authored by hyatt's avatar hyatt

Tweaks to prevent timers from starving user input or painting.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20267 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6690f93b
2007-03-17 Dave Hyatt <hyatt@apple.com>
Prevent starvation of user input and painting when processing timers.
If we are already in the processing of a custom timer message, don't allow that
processing to do another PostMessage. Force SetTimer to be used instead.
Reviewed by ggaren
* platform/win/SharedTimerWin.cpp:
(WebCore::TimerWindowWndProc):
(WebCore::setSharedTimerFireTime):
2007-03-17 Geoffrey Garen <ggaren@apple.com>
Reviewed by Beth Dakin.
......
......@@ -40,12 +40,15 @@ static void (*sharedTimerFiredFunction)();
static HWND timerWindowHandle = 0;
static UINT timerFiredMessage = 0;
const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
static bool processingCustomTimerMessage = false;
LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == timerFiredMessage)
if (message == timerFiredMessage) {
processingCustomTimerMessage = true;
sharedTimerFiredFunction();
else
processingCustomTimerMessage = false;
} else
return DefWindowProc(hWnd, message, wParam, lParam);
return 0;
}
......@@ -94,16 +97,19 @@ void setSharedTimerFireTime(double fireTime)
intervalInMS = (unsigned)interval;
}
if (timerID)
if (timerID) {
KillTimer(0, timerID);
if (intervalInMS == 0) {
timerID = 0;
}
// We don't allow nested PostMessages, since the custom messages will effectively starve
// painting and user input. (Win32 has a tri-level queue with application messages >
// user input > WM_PAINT/WM_TIMER.)
if (intervalInMS < USER_TIMER_MINIMUM && !processingCustomTimerMessage) {
// Windows SetTimer does not allow timeouts smaller than 10ms (USER_TIMER_MINIMUM)
initializeOffScreenTimerWindow();
PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
} else
// FIXME: 1-9ms timeouts may fire too late.
timerID = SetTimer(0, 0, intervalInMS, timerFired);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment