Bug 1683578 [wayland] Use wl_surface ID instead of wl_surface address when check for stored frame callback, r=jhorak

Depends on D104711

Differential Revision: https://phabricator.services.mozilla.com/D104712
This commit is contained in:
stransky 2021-02-11 15:30:17 +00:00
Родитель a3a1f17129
Коммит 06c83032c0
3 изменённых файлов: 23 добавлений и 18 удалений

Просмотреть файл

@ -474,7 +474,7 @@ WindowSurfaceWayland::WindowSurfaceWayland(nsWindow* aWindow)
mWaylandBuffer(nullptr),
mWaylandFullscreenDamage(false),
mFrameCallback(nullptr),
mLastCommittedSurface(nullptr),
mLastCommittedSurfaceID(-1),
mLastCommitTime(0),
mDrawToWaylandBufferDirectly(true),
mCanSwitchWaylandBuffer(true),
@ -812,6 +812,7 @@ already_AddRefed<gfx::DrawTarget> WindowSurfaceWayland::Lock(
mWaylandBufferDamage.SetEmpty();
mCanSwitchWaylandBuffer = true;
mWLBufferIsDirty = false;
mBufferNeedsClear = true;
}
mMozContainerRect = mozContainerSize;
}
@ -978,7 +979,7 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
mDrawToWaylandBufferDirectly));
LOGWAYLAND((" mCanSwitchWaylandBuffer = %d\n", mCanSwitchWaylandBuffer));
LOGWAYLAND((" mFrameCallback = %p\n", mFrameCallback));
LOGWAYLAND((" mLastCommittedSurface = %p\n", mLastCommittedSurface));
LOGWAYLAND((" mLastCommittedSurfaceID = %d\n", mLastCommittedSurfaceID));
LOGWAYLAND((" mWLBufferIsDirty = %d\n", mWLBufferIsDirty));
LOGWAYLAND((" mBufferCommitAllowed = %d\n", mBufferCommitAllowed));
@ -1007,12 +1008,6 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
LOGWAYLAND(
(" moz_container_wayland_surface_lock() failed, delay commit.\n"));
// Target window is not created yet - delay the commit. This can happen only
// when the window is newly created and there's no active
// frame callback pending.
MOZ_ASSERT(!mFrameCallback || waylandSurface != mLastCommittedSurface,
"Missing wayland surface at frame callback!");
if (!mSurfaceReadyTimerID) {
mSurfaceReadyTimerID = g_timeout_add(
EVENT_LOOP_DELAY, &WaylandBufferFlushPendingCommits, this);
@ -1037,18 +1032,22 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
// We have an active frame callback request so handle it.
if (mFrameCallback) {
if (waylandSurface == mLastCommittedSurface) {
LOGWAYLAND((" [%p] wait for frame callback.\n", (void*)this));
int waylandSurfaceID = wl_proxy_get_id((struct wl_proxy*)waylandSurface);
if (waylandSurfaceID == mLastCommittedSurfaceID) {
LOGWAYLAND((" [%p] wait for frame callback ID %d.\n", (void*)this,
waylandSurfaceID));
// We have an active frame callback pending from our recent surface.
// It means we should defer the commit to FrameCallbackHandler().
return true;
}
LOGWAYLAND((" Removing wrong frame callback [%p].\n", mFrameCallback));
LOGWAYLAND((" Removing wrong frame callback [%p] ID %d.\n",
mFrameCallback,
wl_proxy_get_id((struct wl_proxy*)mFrameCallback)));
// If our stored wl_surface does not match the actual one it means the frame
// callback is no longer active and we should release it.
wl_callback_destroy(mFrameCallback);
mFrameCallback = nullptr;
mLastCommittedSurface = nullptr;
mLastCommittedSurfaceID = -1;
}
if (mWaylandFullscreenDamage) {
@ -1077,7 +1076,7 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
wl_callback_add_listener(mFrameCallback, &frame_listener, this);
mWaylandBuffer->Attach(waylandSurface);
mLastCommittedSurface = waylandSurface;
mLastCommittedSurfaceID = wl_proxy_get_id((struct wl_proxy*)waylandSurface);
mLastCommitTime = g_get_monotonic_time() / 1000;
// There's no pending commit, all changes are sent to compositor.
@ -1092,7 +1091,7 @@ void WindowSurfaceWayland::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
gfx::IntRect lockSize = aInvalidRegion.GetBounds().ToUnknownRect();
LOGWAYLAND(
("WindowSurfaceWayland::Commit [%p] damage size [%d, %d] -> [%d x %d] "
"screenSize [%d x %d]\n",
"MozContainer [%d x %d]\n",
(void*)this, lockSize.x, lockSize.y, lockSize.width, lockSize.height,
mMozContainerRect.width, mMozContainerRect.height));
LOGWAYLAND((" mDrawToWaylandBufferDirectly = %d\n",
@ -1117,7 +1116,7 @@ void WindowSurfaceWayland::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
void WindowSurfaceWayland::FrameCallbackHandler() {
MOZ_ASSERT(mFrameCallback != nullptr,
"FrameCallbackHandler() called without valid frame callback!");
MOZ_ASSERT(mLastCommittedSurface != nullptr,
MOZ_ASSERT(mLastCommittedSurfaceID != -1,
"FrameCallbackHandler() called without valid wl_surface!");
LOGWAYLAND(
("WindowSurfaceWayland::FrameCallbackHandler [%p]\n", (void*)this));

Просмотреть файл

@ -211,7 +211,7 @@ class WindowSurfaceWayland : public WindowSurface {
// Any next commit to wayland compositor will happen when frame callback
// comes from wayland compositor back as it's the best time to do the commit.
wl_callback* mFrameCallback;
wl_surface* mLastCommittedSurface;
int mLastCommittedSurfaceID;
// Cached drawings. If we can't get WaylandBuffer (wl_buffer) at
// WindowSurfaceWayland::Lock() we direct gecko rendering to

Просмотреть файл

@ -1786,6 +1786,9 @@ void nsWindow::NativeMoveResizeWaylandPopup(GdkPoint* aPosition,
bool isWidgetVisible =
(sGtkWidgetIsVisible != nullptr) && sGtkWidgetIsVisible(mShell);
if (isWidgetVisible) {
LOG(
(" temporary hide popup due to "
"https://gitlab.gnome.org/GNOME/gtk/issues/1986\n"));
PauseRemoteRenderer();
gtk_widget_hide(mShell);
}
@ -1840,6 +1843,9 @@ void nsWindow::NativeMoveResizeWaylandPopup(GdkPoint* aPosition,
if (isWidgetVisible) {
// We show the popup with the same configuration so no need to call
// ConfigureWaylandPopupWindows() before gtk_widget_show().
LOG(
(" show popup due to "
"https://gitlab.gnome.org/GNOME/gtk/issues/1986\n"));
gtk_widget_show(mShell);
}
}