diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index df573909f672..f569ec7c9b9e 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -709,8 +709,7 @@ bool MessageChannel::CanSend() const { } void MessageChannel::Clear() { - // Don't clear mWorkerThread; we use it in AssertLinkThread() and - // AssertWorkerThread(). + // Don't clear mWorkerThread; we use it in AssertWorkerThread(). // // Also don't clear mListener. If we clear it, then sending a message // through this channel after it's Clear()'ed can cause this process to @@ -1042,7 +1041,6 @@ class CancelMessage : public IPC::Message { }; bool MessageChannel::MaybeInterceptSpecialIOMessage(const Message& aMsg) { - AssertLinkThread(); mMonitor->AssertCurrentThreadOwns(); if (MSG_ROUTING_NONE == aMsg.routing_id()) { @@ -1124,10 +1122,11 @@ bool MessageChannel::ShouldDeferMessage(const Message& aMsg) { } void MessageChannel::OnMessageReceivedFromLink(Message&& aMsg) { - AssertLinkThread(); mMonitor->AssertCurrentThreadOwns(); - if (MaybeInterceptSpecialIOMessage(aMsg)) return; + if (MaybeInterceptSpecialIOMessage(aMsg)) { + return; + } mListener->OnChannelReceivedMessage(aMsg); @@ -1204,8 +1203,8 @@ void MessageChannel::OnMessageReceivedFromLink(Message&& aMsg) { // before returning. bool shouldPostTask = !shouldWakeUp || wakeUpSyncSend; - IPC_LOG("Receive on link thread; seqno=%d, xid=%d, shouldWakeUp=%d", - aMsg.seqno(), aMsg.transaction_id(), shouldWakeUp); + IPC_LOG("Receive from link; seqno=%d, xid=%d, shouldWakeUp=%d", aMsg.seqno(), + aMsg.transaction_id(), shouldWakeUp); if (reuseTask) { return; @@ -2257,7 +2256,7 @@ bool MessageChannel::WaitResponse(bool aWaitTimedOut) { #ifndef OS_WIN bool MessageChannel::WaitForSyncNotify(bool /* aHandleWindowsMessages */) { # ifdef DEBUG - // WARNING: We don't release the lock here. We can't because the link thread + // WARNING: We don't release the lock here. We can't because the link // could signal at this time and we would miss it. Instead we require // ArtificialTimeout() to be extremely simple. if (mListener->ArtificialTimeout()) { @@ -2425,7 +2424,6 @@ bool MessageChannel::MaybeHandleError(Result code, const Message& aMsg, } void MessageChannel::OnChannelErrorFromLink() { - AssertLinkThread(); mMonitor->AssertCurrentThreadOwns(); IPC_LOG("OnChannelErrorFromLink"); diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index f9c279d3a0c0..452106ce9f60 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -553,24 +553,6 @@ class MessageChannel : HasResultCodes { "not on worker thread!"); } - // The "link" thread is either the I/O thread (ProcessLink), the other - // actor's work thread (ThreadLink), or the worker thread (same-thread - // channels). - void AssertLinkThread() const { - if (mIsSameThreadChannel) { - // If we're a same-thread channel, we have to be on our worker - // thread. - AssertWorkerThread(); - return; - } - - // If we aren't a same-thread channel, our "link" thread is _not_ our - // worker thread! - MOZ_ASSERT(mWorkerThread, "Channel hasn't been opened yet"); - MOZ_RELEASE_ASSERT(mWorkerThread && !mWorkerThread->IsOnCurrentThread(), - "on worker thread but should not be!"); - } - private: class MessageTask : public CancelableRunnable, public LinkedListElement>, diff --git a/xpcom/threads/SchedulerGroup.cpp b/xpcom/threads/SchedulerGroup.cpp index f5df42ebecd2..62f4b2c887ce 100644 --- a/xpcom/threads/SchedulerGroup.cpp +++ b/xpcom/threads/SchedulerGroup.cpp @@ -38,20 +38,21 @@ nsresult SchedulerGroup::UnlabeledDispatch( /* static */ void SchedulerGroup::MarkVsyncReceived() { - if (gEarliestUnprocessedVsync) { - // If we've seen a vsync already, but haven't handled it, keep the - // older one. - return; - } - - MOZ_ASSERT(!NS_IsMainThread()); + // May be called on any thread when a vsync is received and scheduled to be + // processed. This may occur on the main thread due to queued messages when + // the channel is connected. bool inconsistent = false; TimeStamp creation = TimeStamp::ProcessCreation(&inconsistent); if (inconsistent) { return; } - gEarliestUnprocessedVsync = (TimeStamp::Now() - creation).ToMicroseconds(); + // Attempt to set gEarliestUnprocessedVsync to our new value. If we've seen a + // vsync already, but haven't handled it, the `compareExchange` will fail and + // the static won't be updated. + uint64_t unprocessedVsync = + uint64_t((TimeStamp::Now() - creation).ToMicroseconds()); + gEarliestUnprocessedVsync.compareExchange(0, unprocessedVsync); } /* static */