This is a legitimate bug. I think this might be the first use of this type: - A menupopup is being mutated while it's open - The menu is not the root menupopup of a context menu From what I can tell, the way the native menu system sets up its mutation observers is bound to cause duplicate notifications: We register the observer on the `<menubar>`, on the context menu's root `<menupopup>`, and on every nested `<menu>`. But mutation observers observe the entire DOM subtree. So we get lots of duplicate mutation callbacks for anything that's nested at least one level deep. And it seems we've always been getting these duplicate callbacks. It's just that, if our observer is called while the menu is closed, we just set a "need to rebuild" flag and return. But when the menu is open, these duplicate notifications cause trouble.
Bug 1926630 Comment 2 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
This is a legitimate bug. I think this might be the first use of this type: - A menupopup is being mutated while it's open - The menu is not the root menupopup of a context menu From what I can tell, [the way the native menu system sets up its mutation observers](https://searchfox.org/mozilla-central/search?q=nsMenuGroupOwnerX%3A%3ARegisterForContentChanges&path=) is bound to cause duplicate notifications: We register the observer on the `<menubar>`, on the context menu's root `<menupopup>`, and on every nested `<menu>`. But mutation observers observe the entire DOM subtree. So we get lots of duplicate mutation callbacks for anything that's nested at least one level deep. And it seems we've always been getting these duplicate callbacks. It's just that, if our observer is called while the menu is closed, we just set a "need to rebuild" flag and return. But when the menu is open, these duplicate notifications cause trouble.