Bug 1880503 - Handle sync IPC timeout in UiCompositorControllerChild. r=aosmond

Extend the sync IPC timeout mechanism in CompositorManagerChild to
additionally cover UiCompositorControllerChild. As
UiCompositorControllerChild runs on the Android UI thread, we ensure
GPUProcessManager::KillProcess dispatches to the gecko main thread.

Along with the previous patch in this series this should provide us
with crash reports when the Android UI thread is hung waiting for the
GPU process to reply.

Differential Revision: https://phabricator.services.mozilla.com/D202167
This commit is contained in:
Jamie Nicol 2024-05-14 12:58:36 +00:00
parent 0056a7ee56
commit becb5e70d3
4 changed files with 30 additions and 0 deletions

View File

@ -212,6 +212,8 @@ void GPUProcessHost::OnChannelClosed() {
}
void GPUProcessHost::KillHard(bool aGenerateMinidump) {
MOZ_ASSERT(NS_IsMainThread());
if (mGPUChild && aGenerateMinidump) {
mGPUChild->GeneratePairedMinidump();
}

View File

@ -1122,6 +1122,13 @@ void GPUProcessManager::CleanShutdown() {
}
void GPUProcessManager::KillProcess(bool aGenerateMinidump) {
if (!NS_IsMainThread()) {
RefPtr<Runnable> task = mTaskFactory.NewRunnableMethod(
&GPUProcessManager::KillProcess, aGenerateMinidump);
NS_DispatchToMainThread(task.forget());
return;
}
if (!mProcess) {
return;
}

View File

@ -13,6 +13,7 @@
#include "mozilla/layers/UiCompositorControllerParent.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/StaticPrefs_layers.h"
#include "mozilla/StaticPtr.h"
#include "nsBaseWidget.h"
#include "nsProxyRelease.h"
@ -287,6 +288,8 @@ void UiCompositorControllerChild::OpenForGPUProcess(
return;
}
SetReplyTimeout();
SendCachedValues();
// Let Ui thread know the connection is open;
RecvToolbarAnimatorMessageFromCompositor(COMPOSITOR_CONTROLLER_OPEN);
@ -346,5 +349,20 @@ void UiCompositorControllerChild::OnCompositorSurfaceChanged(
}
#endif
void UiCompositorControllerChild::SetReplyTimeout() {
#ifndef DEBUG
// Add a timeout for release builds to kill GPU process when it hangs.
const int32_t timeout =
StaticPrefs::layers_gpu_process_ipc_reply_timeout_ms_AtStartup();
SetReplyTimeoutMs(timeout);
#endif
}
bool UiCompositorControllerChild::ShouldContinueFromReplyTimeout() {
gfxCriticalNote << "Killing GPU process due to IPC reply timeout";
gfx::GPUProcessManager::Get()->KillProcess(/* aGenerateMinidump */ true);
return false;
}
} // namespace layers
} // namespace mozilla

View File

@ -94,6 +94,9 @@ class UiCompositorControllerChild final
void OpenForGPUProcess(Endpoint<PUiCompositorControllerChild>&& aEndpoint);
void SendCachedValues();
void SetReplyTimeout();
bool ShouldContinueFromReplyTimeout() override;
bool mIsOpen;
uint64_t mProcessToken;
Maybe<gfx::IntRect> mResize;