Open Bug 1955803 Opened 28 days ago Updated 4 days ago

Context menu is providing too many options, many of which don't work or are broken

Categories

(Toolkit :: UI Widgets, defect)

Firefox 136
Desktop
All
defect

Tracking

()

People

(Reporter: knenad, Unassigned, NeedInfo)

References

Details

Attachments

(5 files)

Attached image scrmoz.png

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0

Steps to reproduce:

  1. Go to https://www.reddit.com/r/BuyCanadian/comments/1jcfuud/just_wanted_to_share/
  2. Click on the image to get a better view
  3. Elbows up
  4. Right click on the image and see attached screenshot

Actual results:

It seems like this img element is being misinterpreted as an image, video or audio content at the same time (as well as a piece of text with a phone number, password and an e-mail?). Further, there are some empty context menu items on the bottom which don't seem to do anything.

Expected results:

A context menu which aligns with the JPEG image content should pop up.

The Bugbug bot thinks this bug should belong to the 'Toolkit::Password Manager' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Password Manager
Product: Firefox → Toolkit
Component: Password Manager → UI Widgets

We have some reports where the unnecessary context menu items aren't hidden.

If this is still happening in your browser, can you check the Browser Console to see if there's any error reported?

In the other reports, restarting the browser made the issue disappear, so it might be something intermittent, or maybe one-time thing,
but still it's nice to figure out the underlying issue and we'd like to fix it.

Flags: needinfo?(knenad)
See Also: → 1954885
Flags: needinfo?(knenad)

I've attached a new screenshot. It appears the issue started happening on other websites as well. In this new screenshot, I'm using a private window with the console open, pointing to example.com. I'm not noticing anything that would indicate a failure.

I'll refrain from restarting Firefox for now, just in case there's another way you'd like me to debug this or provide you with more information.

Duplicate of this bug: 1954885
Severity: -- → S2
Summary: Context menu on an <img> element is providing too many options, many of which don't work or are broken → Context menu is providing too many options, many of which don't work or are broken
OS: Unspecified → All
Hardware: Unspecified → Desktop
Status: UNCONFIRMED → NEW
Ever confirmed: true

(In reply to Nenad Kozul from comment #4)

I've attached a new screenshot. It appears the issue started happening on other websites as well. In this new screenshot, I'm using a private window with the console open, pointing to example.com. I'm not noticing anything that would indicate a failure.

I'll refrain from restarting Firefox for now, just in case there's another way you'd like me to debug this or provide you with more information.

The screenshot shows the regular developer tools console. Can you try the instructions linked to check the browser console to see errors that are happening in the browser code? Thanks!

Flags: needinfo?(knenad)
Attached image scr-browser-console.png
Flags: needinfo?(knenad)

Sure thing! See the new attachment (scr-browser-console.png).

This pops up upon a right click:

17:29:40.876 Uncaught TypeError: window.gBrowser.selectedBrowser is undefined
    init resource:///modules/GenAI.sys.mjs:352
    init resource:///modules/GenAI.sys.mjs:351
    <anonymous> resource:///modules/GenAI.sys.mjs:1089
    task resource:///modules/BrowserGlue.sys.mjs:3094
    _scheduleStartupIdleTasks resource:///modules/BrowserGlue.sys.mjs:3219
GenAI.sys.mjs:352:23

Dismissing the menu with a left click produces:

17:29:38.933 Uncaught TypeError: gContextMenu is null
    <anonymous> chrome://browser/content/browser-context.js:339
browser-context.js:339:7

Some additional errors when right clicking on this very page:

18:46:13.455 Uncaught (in promise) Error: Cannot find menu item with id open-in-this-container undefined
18:46:13.455 Uncaught (in promise) Error: Cannot find menu item with id remove-open-in-this-container undefined
18:46:13.455 Uncaught (in promise) Error: Cannot find menu item with id separator undefined
18:46:13.456 Uncaught (in promise) Error: Cannot find menu item with id hide-container undefined
18:46:13.456 Uncaught (in promise) Error: Cannot find menu item with id move-to-new-window-container undefined
18:46:13.457 Uncaught (in promise) Error: Cannot find menu item with id open-in-this-container undefined
18:46:13.457 Uncaught (in promise) Error: Cannot find menu item with id remove-open-in-this-container undefined
18:46:13.457 Uncaught (in promise) Error: Cannot find menu item with id separator undefined
18:46:13.457 Uncaught (in promise) Error: Cannot find menu item with id hide-container undefined
18:46:13.457 Uncaught (in promise) Error: Cannot find menu item with id move-to-new-window-container undefined
18:46:13.541 Uncaught TypeError: window.gBrowser.selectedBrowser is undefined
    init resource:///modules/GenAI.sys.mjs:352
    init resource:///modules/GenAI.sys.mjs:351
    <anonymous> resource:///modules/GenAI.sys.mjs:1089
    task resource:///modules/BrowserGlue.sys.mjs:3094
    _scheduleStartupIdleTasks resource:///modules/BrowserGlue.sys.mjs:3219
GenAI.sys.mjs:352:23
18:46:14.732 Uncaught TypeError: gContextMenu is null
    <anonymous> chrome://browser/content/browser-context.js:339
browser-context.js:339:7
18:46:14.748 Uncaught (in promise) Error: Cannot find menu item with id open-in-this-container undefined
18:46:14.748 Uncaught (in promise) Error: Cannot find menu item with id remove-open-in-this-container undefined
18:46:14.749 Uncaught (in promise) Error: Cannot find menu item with id separator undefined
18:46:14.749 Uncaught (in promise) Error: Cannot find menu item with id hide-container undefined
18:46:14.749 Uncaught (in promise) Error: Cannot find menu item with id move-to-new-window-container undefined

The errors in comment #9 point at bug 1688743. I would expect that even if extension code that tries to insert extensions fails, that doesn't break the entirety of the context menu, but let's check in with Rob.

The other error points at https://searchfox.org/mozilla-release/rev/62f34235d373482fc8c3c6a07f3a60c3e224d642/browser/components/genai/GenAI.sys.mjs#352 but really that just means that something strange has happened: the tabbrowser code started up without figuring out a selected browser (and the GenAI.init code doesn't seem to do anything important after that, and the exception will be caught and was reported from here without breaking anything else). But there doesn't appear to be any other error that points to why that might be the case. Dão, I don't suppose you have ideas as to what might be going wrong there or how we'd find out?

Flags: needinfo?(rob)
Flags: needinfo?(dao+bmo)

Reporter (Nenad), could you open a new browser window and see if the issue is also happening there? And if yes, can you share the browser console's content again?

(In reply to :Gijs (he/him) from comment #10)

The errors in comment #9 point at bug 1688743. I would expect that even if extension code that tries to insert extensions fails, that doesn't break the entirety of the context menu, but let's check in with Rob.

This is unrelated. These extension-specific logs are independent of context menu creation themselves. I have seen them before, and just reported the issue at https://github.com/mozilla/multi-account-containers/issues/2735.

The other error points at https://searchfox.org/mozilla-release/rev/62f34235d373482fc8c3c6a07f3a60c3e224d642/browser/components/genai/GenAI.sys.mjs#352

FWIW, that code was removed in bug 1951311. The observed error here seems independent of the caller though.

The unexpected state (gBrowser.selectedBrowser being undefined) suggests that any of the following may be happening:

  • _setupInitialBrowserAndTab never reached the point of initializing _selectedBrowser.
  • updateCurrentBrowser was called while tabContainer.selectedIndex pointed to an invalid position.
  • some other state got corrupted, e.g. cache or browser artifacts, to the point that reading code to infer logic is not productive.
    • If the issue is consistently reproducible, even in a new window, then this theory seems not unlikely.
Flags: needinfo?(rob) → needinfo?(knenad)
New window: ``` ```

See: Console log of new Window in attachments.

As soon as I focus on the new window, I get the "Cannot find menu item with id" errors. Upon a right click, the window.gBrowser.selectedBrowser is undefined error occurs.

Also, my understanding is that I should just create a new FF window to test this (and NOT restart Firefox just yet), correct?

Flags: needinfo?(knenad)

One additional note:

The "cannot find menu item" errors occur in the Multiprocess (Slower) browser console, as well as the "window.gBrowser.selectedBrowser is undefined" error.

In Parent process only (fast) mode, I only get "window.gBrowser.selectedBrowser is undefined" to appear.

Yes, in a new window, WITHOUT restarting Firefox (because that would most likely get rid off the issue, so that it cannot be debugged any more).

Odd, strange that you're able to reproduce this consistently. I'd like to do some sanity checks to understand the state you're in.
Since you are able to reproduce this for every window, run the following steps:

  1. Visit about:config (any privileged page would do) and open the Developer Tools (right-click, Inspect, Console).
  2. Copy-paste the following code and run it: windowRoot.ownerGlobal.gBrowser._notificationEnableDelay
    • The result should be 500. If it is undefined, that could be a sign that this code has never been reached.
  3. Copy-paste the following code and run it: windowRoot.ownerGlobal.gBrowser._selectedBrowser
    • If this value is still undefined, then you have some really broken unexpected state.
    • If this value is set, then whatever that triggered the logged error via GenAI.sys.mjs got fixed in the meantime.
  4. I would expect the _scheduleStartupIdleTasks part to be triggered once, at browser startup. The fact that you see it again for new browser windows is somewhat surprising. To find out what triggers it, could you:
    1. Copy-paste the following code and run it: Services.obs.addObserver({ observe(subject, topic){ Services.obs.removeObserver(this, topic); console.trace("Hello world"); }}, "sessionstore-windows-restored")
    2. Open a new browser window.
    3. Go back to the original console where you ran the previous code, and look at the console. What is the content (stack trace)? Given your bug, I expect to see "Hello world" there.

Please share the output of each step here. If you run all steps at once, you can copy the output all at once in the end, and share it here.

Flags: needinfo?(knenad)
  1. Visited and opened developer tools
  2. Indeed, a 500 is the result:
>> windowRoot.ownerGlobal.gBrowser._notificationEnableDelay
<< 500 
  1. It's not undefined:
>> windowRoot.ownerGlobal.gBrowser._selectedBrowser
<< <browser contextmenu="contentAreaContextMenu" message="true" messagemanagergroup="browsers" tooltip="aHTMLTooltip" type="content" manualactiveness="true" maychangeremoteness="true" remote="false" autocompletepopup="PopupAutoComplete" initialBrowsingContextGroupId="1148" nodefaultsrc="true" primary="true">
  1. I am not receiving "Hello world".
>>  Services.obs.addObserver({ observe(subject, topic){ Services.obs.removeObserver(this, topic); console.trace("Hello world"); }}, "sessionstore-windows-restored")
<< undefined 

After the above command, at no point have I seen a "hello world" in any console. Screenshot will be attached.

Flags: needinfo?(knenad)

Can you filter by Parent Process only? The logs of interest are in that context.

When you followed the steps to get to the output in comment 16, was the originally reported issue still present? I.e. context menu not working in that window.

The log you shared before in comment 12 suggested that the same bug was observed with the new window. I drew that conclusion because the timestamps differ from the logs shared in comment 9. I can however not see the same errors in the log in comment 17.

Yes, the originally reported issue is still present. The context menu is overflowing with non-functional elements.

Here's a video of the whole flow: https://drive.google.com/file/d/1oY-ngqY5uDOPsPy5HeJt2OkCRsGindqc/view (4K, can't fit the 10MB bugzilla limit here)

See Also: → 1957189
Duplicate of this bug: 1957338
Duplicate of this bug: 1957189

Is this still happening in the latest Firefox 137.0.2? If so, have the error messages changed? Please can you copy and paste any new/different errors as an attachment (text is generally easier to read than images).

Flags: needinfo?(dao+bmo) → needinfo?(knenad)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: