From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/canvas/WebGLChild.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'dom/canvas/WebGLChild.cpp') diff --git a/dom/canvas/WebGLChild.cpp b/dom/canvas/WebGLChild.cpp index cf676c2f53..ebfe35db88 100644 --- a/dom/canvas/WebGLChild.cpp +++ b/dom/canvas/WebGLChild.cpp @@ -87,10 +87,8 @@ void WebGLChild::FlushPendingCmds() { // Handle flushesSinceLastCongestionCheck mFlushedCmdInfo.flushesSinceLastCongestionCheck += 1; - const auto startCongestionCheck = 20; - const auto maybeIPCMessageCongestion = 70; - const auto eventTarget = GetCurrentSerialEventTarget(); - MOZ_ASSERT(eventTarget); + constexpr auto START_CONGESTION_CHECK_THRESHOLD = 20; + constexpr auto ASSUME_IPC_CONGESTION_THRESHOLD = 70; RefPtr self = this; size_t generation = self->mFlushedCmdInfo.congestionCheckGeneration; @@ -107,17 +105,24 @@ void WebGLChild::FlushPendingCmds() { // messages. // Due to the async nature of the async ping, it is possible for the flush // check to exceed maybeIPCMessageCongestion, but that it it still bounded. - if (mFlushedCmdInfo.flushesSinceLastCongestionCheck == startCongestionCheck) { - SendPing()->Then(eventTarget, __func__, [self, generation]() { - if (generation == self->mFlushedCmdInfo.congestionCheckGeneration) { - // Confirmed IPC messages congestion does not happen. - // Reset flushesSinceLastCongestionCheck for next congestion check. - self->mFlushedCmdInfo.flushesSinceLastCongestionCheck = 0; - self->mFlushedCmdInfo.congestionCheckGeneration++; - } - }); + if (mFlushedCmdInfo.flushesSinceLastCongestionCheck == + START_CONGESTION_CHECK_THRESHOLD) { + const auto eventTarget = RefPtr{GetCurrentSerialEventTarget()}; + MOZ_ASSERT(eventTarget); + if (!eventTarget) { + NS_WARNING("GetCurrentSerialEventTarget()->nullptr in FlushPendingCmds."); + } else { + SendPing()->Then(eventTarget, __func__, [self, generation]() { + if (generation == self->mFlushedCmdInfo.congestionCheckGeneration) { + // Confirmed IPC messages congestion does not happen. + // Reset flushesSinceLastCongestionCheck for next congestion check. + self->mFlushedCmdInfo.flushesSinceLastCongestionCheck = 0; + self->mFlushedCmdInfo.congestionCheckGeneration++; + } + }); + } } else if (mFlushedCmdInfo.flushesSinceLastCongestionCheck > - maybeIPCMessageCongestion) { + ASSUME_IPC_CONGESTION_THRESHOLD) { // IPC messages congestion might happen, send sync SyncPing for flushing // pending messages. SendSyncPing(); -- cgit v1.2.3