-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Win] Fix Wasm Compilation From Web Worker #32602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Win] Fix Wasm Compilation From Web Worker #32602
Conversation
EWS run on previous version of this PR (hash 29b445b) |
29b445b
to
962cfb9
Compare
EWS run on previous version of this PR (hash 962cfb9) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
@@ -170,7 +179,8 @@ void RunLoop::TimerBase::start(Seconds interval, bool repeat) | |||
m_isActive = true; | |||
m_interval = interval; | |||
m_nextFireDate = MonotonicTime::timePointFromNow(m_interval); | |||
::SetTimer(m_runLoop->m_runLoopMessageWindow, bitwise_cast<uintptr_t>(this), interval.millisecondsAs<UINT>(), nullptr); | |||
m_runLoop->m_liveTimers.add(bitwise_cast<uintptr_t>(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this accessing m_liveTimers
from multiple threads without locking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_runLoop->m_loopLock
is held here and inside RunLoop::TimerBase::stop
when we call m_liveTimers.remove
.
The m_runLoop->m_loopLock
isn't held when we do the m_liveTimers.contains
check inside wndProc. I could take the m_runLoop->m_loopLock
there as well - if it's live we take it after we call timerFired() anyway.
962cfb9
to
a7ddab5
Compare
EWS run on previous version of this PR (hash a7ddab5) |
a7ddab5
to
4152509
Compare
EWS run on current version of this PR (hash 4152509) |
https://bugs.webkit.org/show_bug.cgi?id=267323 Reviewed by Yusuke Suzuki. We were calling SetTimer from the wasm compilation thread, which isn't the thread that owns the run loop message window. That silently failed, the timer wass never registered / fires as it's on the wrong thread. In addition - the WorkerRunLoop was not cycling the window message pump run loop - on other platforms this worked as both run loops used similar message queue mechanisms. We could fix this through wrapping timer start operations in a run loop dispatch(), but that increases complexity through introducing another source / type of async tasks in the loop. There's also a number of call sites, and the risk of additional call sites being added with Windows being the only platform where TimerBase::start() must be called on the run loop thread. We could also fix this through using run loop dispatch inside TimerBase::start() / TimerBase::stop() - however it's difficult to capture the TimerBase safely for the dispatch lambda with various subclasses of TimerBase involved. This is necessary because the dispatch introduces cases where the timer is destroyed before the dispatch callback runs. The solution used here is to make RunLoopWin PostMessage to the window for scheduling / killing timers, so it can call SetTimer / KillTimer from the correct thread. A HashSet is used in addition to keep track of live timers - as sometimes a timer is able to fire but not have the WM_TIMER event processed before KillTimer (and the timer destructor running). WorkerRunLoop calls RunLoop::cycle, and adjusts it's timeout based on when the next deferredWorkTimer will fire. * Source/WTF/wtf/RunLoop.h: * Source/WTF/wtf/win/RunLoopWin.cpp: (WTF::RunLoop::wndProc): (WTF::RunLoop::TimerBase::start): (WTF::RunLoop::TimerBase::stop): * Source/WebCore/workers/WorkerRunLoop.cpp: (WebCore::WorkerDedicatedRunLoop::runInMode): Canonical link: https://commits.webkit.org/282906@main
4152509
to
f659dfd
Compare
Committed 282906@main (f659dfd): https://commits.webkit.org/282906@main Reviewed commits have been landed. Closing PR #32602 and removing active labels. |
f659dfd
4152509