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), mWaylandBuffer(nullptr),
mWaylandFullscreenDamage(false), mWaylandFullscreenDamage(false),
mFrameCallback(nullptr), mFrameCallback(nullptr),
mLastCommittedSurface(nullptr), mLastCommittedSurfaceID(-1),
mLastCommitTime(0), mLastCommitTime(0),
mDrawToWaylandBufferDirectly(true), mDrawToWaylandBufferDirectly(true),
mCanSwitchWaylandBuffer(true), mCanSwitchWaylandBuffer(true),
@ -812,6 +812,7 @@ already_AddRefed<gfx::DrawTarget> WindowSurfaceWayland::Lock(
mWaylandBufferDamage.SetEmpty(); mWaylandBufferDamage.SetEmpty();
mCanSwitchWaylandBuffer = true; mCanSwitchWaylandBuffer = true;
mWLBufferIsDirty = false; mWLBufferIsDirty = false;
mBufferNeedsClear = true;
} }
mMozContainerRect = mozContainerSize; mMozContainerRect = mozContainerSize;
} }
@ -978,7 +979,7 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
mDrawToWaylandBufferDirectly)); mDrawToWaylandBufferDirectly));
LOGWAYLAND((" mCanSwitchWaylandBuffer = %d\n", mCanSwitchWaylandBuffer)); LOGWAYLAND((" mCanSwitchWaylandBuffer = %d\n", mCanSwitchWaylandBuffer));
LOGWAYLAND((" mFrameCallback = %p\n", mFrameCallback)); LOGWAYLAND((" mFrameCallback = %p\n", mFrameCallback));
LOGWAYLAND((" mLastCommittedSurface = %p\n", mLastCommittedSurface)); LOGWAYLAND((" mLastCommittedSurfaceID = %d\n", mLastCommittedSurfaceID));
LOGWAYLAND((" mWLBufferIsDirty = %d\n", mWLBufferIsDirty)); LOGWAYLAND((" mWLBufferIsDirty = %d\n", mWLBufferIsDirty));
LOGWAYLAND((" mBufferCommitAllowed = %d\n", mBufferCommitAllowed)); LOGWAYLAND((" mBufferCommitAllowed = %d\n", mBufferCommitAllowed));
@ -1007,12 +1008,6 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
LOGWAYLAND( LOGWAYLAND(
(" moz_container_wayland_surface_lock() failed, delay commit.\n")); (" 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) { if (!mSurfaceReadyTimerID) {
mSurfaceReadyTimerID = g_timeout_add( mSurfaceReadyTimerID = g_timeout_add(
EVENT_LOOP_DELAY, &WaylandBufferFlushPendingCommits, this); EVENT_LOOP_DELAY, &WaylandBufferFlushPendingCommits, this);
@ -1037,18 +1032,22 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
// We have an active frame callback request so handle it. // We have an active frame callback request so handle it.
if (mFrameCallback) { if (mFrameCallback) {
if (waylandSurface == mLastCommittedSurface) { int waylandSurfaceID = wl_proxy_get_id((struct wl_proxy*)waylandSurface);
LOGWAYLAND((" [%p] wait for frame callback.\n", (void*)this)); 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. // We have an active frame callback pending from our recent surface.
// It means we should defer the commit to FrameCallbackHandler(). // It means we should defer the commit to FrameCallbackHandler().
return true; 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 // 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. // callback is no longer active and we should release it.
wl_callback_destroy(mFrameCallback); wl_callback_destroy(mFrameCallback);
mFrameCallback = nullptr; mFrameCallback = nullptr;
mLastCommittedSurface = nullptr; mLastCommittedSurfaceID = -1;
} }
if (mWaylandFullscreenDamage) { if (mWaylandFullscreenDamage) {
@ -1077,7 +1076,7 @@ bool WindowSurfaceWayland::FlushPendingCommitsLocked() {
wl_callback_add_listener(mFrameCallback, &frame_listener, this); wl_callback_add_listener(mFrameCallback, &frame_listener, this);
mWaylandBuffer->Attach(waylandSurface); mWaylandBuffer->Attach(waylandSurface);
mLastCommittedSurface = waylandSurface; mLastCommittedSurfaceID = wl_proxy_get_id((struct wl_proxy*)waylandSurface);
mLastCommitTime = g_get_monotonic_time() / 1000; mLastCommitTime = g_get_monotonic_time() / 1000;
// There's no pending commit, all changes are sent to compositor. // 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(); gfx::IntRect lockSize = aInvalidRegion.GetBounds().ToUnknownRect();
LOGWAYLAND( LOGWAYLAND(
("WindowSurfaceWayland::Commit [%p] damage size [%d, %d] -> [%d x %d] " ("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, (void*)this, lockSize.x, lockSize.y, lockSize.width, lockSize.height,
mMozContainerRect.width, mMozContainerRect.height)); mMozContainerRect.width, mMozContainerRect.height));
LOGWAYLAND((" mDrawToWaylandBufferDirectly = %d\n", LOGWAYLAND((" mDrawToWaylandBufferDirectly = %d\n",
@ -1117,7 +1116,7 @@ void WindowSurfaceWayland::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
void WindowSurfaceWayland::FrameCallbackHandler() { void WindowSurfaceWayland::FrameCallbackHandler() {
MOZ_ASSERT(mFrameCallback != nullptr, MOZ_ASSERT(mFrameCallback != nullptr,
"FrameCallbackHandler() called without valid frame callback!"); "FrameCallbackHandler() called without valid frame callback!");
MOZ_ASSERT(mLastCommittedSurface != nullptr, MOZ_ASSERT(mLastCommittedSurfaceID != -1,
"FrameCallbackHandler() called without valid wl_surface!"); "FrameCallbackHandler() called without valid wl_surface!");
LOGWAYLAND( LOGWAYLAND(
("WindowSurfaceWayland::FrameCallbackHandler [%p]\n", (void*)this)); ("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 // 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. // comes from wayland compositor back as it's the best time to do the commit.
wl_callback* mFrameCallback; wl_callback* mFrameCallback;
wl_surface* mLastCommittedSurface; int mLastCommittedSurfaceID;
// Cached drawings. If we can't get WaylandBuffer (wl_buffer) at // Cached drawings. If we can't get WaylandBuffer (wl_buffer) at
// WindowSurfaceWayland::Lock() we direct gecko rendering to // WindowSurfaceWayland::Lock() we direct gecko rendering to

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

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