Closed Bug 1720551 Opened 4 years ago Closed 3 years ago

[wayland] popup is wrongly anchored in RTL

Categories

(Core :: Widget: Gtk, defect, P2)

Firefox 89
defect

Tracking

()

RESOLVED FIXED
93 Branch
Tracking Status
firefox-esr78 --- wontfix
firefox-esr91 --- wontfix
firefox91 --- wontfix
firefox92 --- wontfix
firefox93 --- fixed

People

(Reporter: sarmad, Assigned: stransky)

References

(Blocks 2 open bugs)

Details

(Keywords: crash)

Crash Data

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0

Steps to reproduce:

  • Start firefox in Arabic (right to left layout)
  • Click the Application Menu button, or on a button of an extension that displays a menu.

Actual results:

Menu is not displayed. Sometimes the whole Firefox crashes.

Additional Details:

  • It worked for a while, but once it started crashing it became 100% reproducible.
  • This was tested on a fresh installation of Ubuntu 21.04, as well as a non-fresh installation of Pop OS 21.04, in Wayland session for both.
  • Removing the entire ~/.mozilla folder does not help. Reinstalling firefox also does not help.
  • Switching the language to English by simply running LANG=en firefox solves the issue.
  • Switching to X11 seems to fix the issue as well.

Expected results:

Should work and display the menu correctly.

Flags: needinfo?(sarmad)
Flags: needinfo?(sarmad)

Here is a bit more details I discovered:

  • The issue of menu not showing up seems to be a Gnome/Wayland issue. The same behaviour happens in other GTK based apps, like Gnome Terminal's pop up menu.
  • The crash isn't 100% reproducible with the missing menu issue. The crash happened few times after I clicked the menu, but I'm not 100% sure the crash is a result of the same issue.
  • The missing menu seems to be related to the position of the menu on the screen, and to multi monitor setups. Here is how to reproduce the issue (again, this can also be reproduced in other apps):
    • Use Ubuntu 21.04 or Pop OS 21.04
    • Login using Wayland session.
    • Set the language to Arabic (it's probably reproducible in other RTL languages as well)
    • Attach a secondary monitor.
    • Put the Firefox window on a monitor that isn't the left most.
    • Either maximize the Firefox window, or move it close to the left edge of the monitor.
    • Click the main menu button.
Crash Signature: [@ InvalidArrayIndex_CRASH | ClusterIterator::ClusterIterator]
Component: Untriaged → Layout: Text and Fonts
Keywords: crash
Product: Firefox → Core
Summary: firefox crash when language is set to Arabic → firefox crash when language is set to Arabic (Crash in [@ InvalidArrayIndex_CRASH | ClusterIterator::ClusterIterator])

Confirming based on crash-stats reports.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Per comment 0 it seems this is specific to wayland.

I can try to repro this somehow.

Flags: needinfo?(emilio)

So I can't repro the crash on Nightly, but the popup is busted, because it's anchored to the left, outside of the window. Screenshots incoming.

Summary: firefox crash when language is set to Arabic (Crash in [@ InvalidArrayIndex_CRASH | ClusterIterator::ClusterIterator]) → [wayland] popup is wrongly anchored in RTL
Attached image X11
Attached image wayland

The wayland behavior looks specially broken because if there's no enough space to the right, the popup doesn't appear at all. Martin, is this known?

Flags: needinfo?(emilio) → needinfo?(stransky)
Component: Layout: Text and Fonts → Widget: Gtk

(In reply to Emilio Cobos Álvarez (:emilio) from comment #9)

Created attachment 9233956 [details]
wayland

The wayland behavior looks specially broken because if there's no enough space to the right, the popup doesn't appear at all. Martin, is this known?

Missing popup is a Mutter bug - https://gitlab.gnome.org/GNOME/mutter/-/issues/1768

Wrong anchor needs to be fixed.

Flags: needinfo?(stransky)
Priority: -- → P2

Emilio, how can I enable the RTL popup direction in nightly (custom builds)?
Thanks.

Flags: needinfo?(emilio)

intl.l10n.pseudo=bidi

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #12)

intl.l10n.pseudo=bidi

Awesome, Thanks!

Looks like we need to export IsDirectionRTL() from PopupFrame and adjust move-to-rect setup for it. All popup are placed as LTR by default.

Gtk uses:

  if (text_direction == GTK_TEXT_DIR_RTL)
    {
      rect_anchor = get_horizontally_flipped_anchor (rect_anchor);
      menu_anchor = get_horizontally_flipped_anchor (menu_anchor);
    }

so we need to something similar for RTL locales.

Assignee: nobody → stransky
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/8b346c50a44c [Wayland] Update popup anchor for RTL locales, r=emilio
Backout by imoraru@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f6a0ed223987 Backed out changeset 8b346c50a44c for causing bc failures on browser_test_clipboardcache.js. CLOSED TREE

Are you sure this was causing those failures? This patch is Linux-only, and those failures are on Windows.

Flags: needinfo?(sheriffs)
Pushed by nbeleuzu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/eacd6f08df5e [Wayland] Update popup anchor for RTL locales, r=emilio
Flags: needinfo?(stransky)
Flags: needinfo?(sheriffs)
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch

Is this something we should keep on the radar for an eventual ESR91 backport?

(In reply to Ryan VanderMeulen [:RyanVM] from comment #23)

Is this something we should keep on the radar for an eventual ESR91 backport?

No need for that, Wayland should not be shipped for 91 ESR.

Flags: needinfo?(stransky)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: