Skip to content

Commit

Permalink
Bug 1875980 - Always notify context lost RemoteTextureOwner in WebGLC…
Browse files Browse the repository at this point in the history
…ontext::Present() r=gfx-reviewers,lsalzman

During testing Bug 1863257, there were cases that test failed with timeout in RemoteTextureMap::WaitRemoteTextureReady(). In this case, RemoteTextureOwner was not registered since first Surface allocation was failed at GeckoProcessManager.getSurfaceAllocator().

Even with the case, RemoteTextureOwner should be registered as context lost.

Differential Revision: https://phabricator.services.mozilla.com/D199312
  • Loading branch information
sotaro committed Jan 23, 2024
1 parent ef187b5 commit 0f00b77
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
30 changes: 29 additions & 1 deletion dom/canvas/WebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,10 @@ void WebGLContext::Present(WebGLFramebuffer* const xrFb,
const bool webvr,
const webgl::SwapChainOptions& options) {
const FuncScope funcScope(*this, "<Present>");
if (IsContextLost()) return;
if (IsContextLost()) {
EnsureContextLostRemoteTextureOwner(options);
return;
}

auto swapChain = GetSwapChain(xrFb, webvr);
const gl::MozFramebuffer* maybeFB = nullptr;
Expand All @@ -1068,6 +1071,7 @@ void WebGLContext::Present(WebGLFramebuffer* const xrFb,
bool valid =
maybeFB ? PresentIntoXR(*swapChain, *maybeFB) : PresentInto(*swapChain);
if (!valid) {
EnsureContextLostRemoteTextureOwner(options);
return;
}

Expand Down Expand Up @@ -1268,6 +1272,30 @@ bool WebGLContext::PushRemoteTexture(
return true;
}

void WebGLContext::EnsureContextLostRemoteTextureOwner(
const webgl::SwapChainOptions& options) {
if (!options.remoteTextureOwnerId.IsValid()) {
return;
}

if (!mRemoteTextureOwner) {
// Ensure we have a remote texture owner client for WebGLParent.
const auto* outOfProcess = mHost ? mHost->mOwnerData.outOfProcess : nullptr;
if (!outOfProcess) {
return;
}
auto pid = outOfProcess->OtherPid();
mRemoteTextureOwner = MakeRefPtr<layers::RemoteTextureOwnerClient>(pid);
}

layers::RemoteTextureOwnerId ownerId = options.remoteTextureOwnerId;

if (!mRemoteTextureOwner->IsRegistered(ownerId)) {
mRemoteTextureOwner->RegisterTextureOwner(ownerId);
}
mRemoteTextureOwner->NotifyContextLost();
}

void WebGLContext::EndOfFrame() {
const FuncScope funcScope(*this, "<EndOfFrame>");
if (IsContextLost()) return;
Expand Down
3 changes: 3 additions & 0 deletions dom/canvas/WebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
const webgl::SwapChainOptions& options,
layers::RemoteTextureOwnerClient* ownerClient = nullptr);

void EnsureContextLostRemoteTextureOwner(
const webgl::SwapChainOptions& options);

// --

bool EnsureDefaultFB();
Expand Down
6 changes: 4 additions & 2 deletions third_party/wayland-proxy/wayland-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ bool WaylandProxy::SetupWaylandDisplays() {
if (!waylandDisplay) {
waylandDisplay = getenv("WAYLAND_DISPLAY");
if (!waylandDisplay) {
Error("Init(), Missing Wayland display, WAYLAND_DISPLAY is empty.", false);
Error("Init(), Missing Wayland display, WAYLAND_DISPLAY is empty.",
false);
return false;
}
}
Expand Down Expand Up @@ -555,7 +556,8 @@ void WaylandProxy::RestoreWaylandDisplay() {
unlink(mWaylandProxy);
char* waylandDisplay = getenv("WAYLAND_DISPLAY_COMPOSITOR");
if (waylandDisplay) {
Info("RestoreWaylandDisplay() WAYLAND_DISPLAY restored to %s\n", waylandDisplay);
Info("RestoreWaylandDisplay() WAYLAND_DISPLAY restored to %s\n",
waylandDisplay);
setenv("WAYLAND_DISPLAY", waylandDisplay, /* overwrite = */ true);
unsetenv("WAYLAND_DISPLAY_COMPOSITOR");
}
Expand Down

0 comments on commit 0f00b77

Please sign in to comment.