Closed Bug 1673958 Opened 5 years ago Closed 5 years ago

Defective implementation of the MozElements.NotificationBox

Categories

(Thunderbird :: Mail Window Front End, defect, P2)

Tracking

(thunderbird_esr68 wontfix, thunderbird_esr78+ wontfix, thunderbird83- wontfix)

RESOLVED FIXED
85 Branch
Tracking Status
thunderbird_esr68 --- wontfix
thunderbird_esr78 + wontfix
thunderbird83 - wontfix

People

(Reporter: aleca, Assigned: aleca)

References

Details

(Keywords: regression)

Attachments

(1 file, 4 obsolete files)

While working on another bug, i noticed a defective behaviour when triggering multiple notifications in the mail front-end.
The notifications don't stack on top of each other and are not ordered by priority, instead they are added one after another as the markup generates a new legacy-stack for every notification.

This is due to a mistake during the first de-xbl conversion, and that's totally my fault as I did that.
https://searchfox.org/comm-central/rev/aa6ec7ca8813e82b76168e76f6cd706ed226bdcd/mail/base/content/mail3PaneWindowCommands.js#32

Example:

  get notificationbox() {
    delete this.notificationbox;

    let newNotificationBox = new MozElements.NotificationBox(element => {
      element.setAttribute("flex", "1");
      element.setAttribute("notificationside", "bottom");
      document.getElementById("messenger-notification-footer").append(element);
    });

    return (this.notificationbox = newNotificationBox);
  }

First there's a risk of too much recursion since we're using the notificationbox getter and then deleting inside itself before generating a new NotificationBox element.
Also, since we're generating a new element at every call, we will never be able to properly stack notifications as we create a new container every time.

I think this was never reported, or even noticed, since I suspect we never show more than 1 notification at a time, therefore extremely rare to reproduce.

Attached patch 1673958-notifications.diff (obsolete) — Splinter Review

Some much needed clean up and fixes.

Here's a try run to see how many things I broke: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=cda74cf2abe060d18dcf0bc68878d0264936b42d

Attachment #9184651 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9184651 [details] [diff] [review] 1673958-notifications.diff Review of attachment 9184651 [details] [diff] [review]: ----------------------------------------------------------------- LGTM, r=mkmelin Unfortunate things are not more centralized, but it is what it is.
Attachment #9184651 - Flags: review?(philipp)
Attachment #9184651 - Flags: review?(mkmelin+mozilla)
Attachment #9184651 - Flags: review+

Unfortunate things are not more centralized, but it is what it is.

Indeed.
Do you think would be worth exploring the possibility of centralizing these notifications in a follow up bug?
Maybe a CE?

Not sure it's very doable.

Any update from Philipp?
If he's super busy, is there someone else that can review Calendar code?

Comment on attachment 9184651 [details] [diff] [review] 1673958-notifications.diff Review of attachment 9184651 [details] [diff] [review]: ----------------------------------------------------------------- Yes, Geoff is back, and eagerly awaiting reviews, I'm sure ;)
Attachment #9184651 - Flags: review?(geoff)
Comment on attachment 9184651 [details] [diff] [review] 1673958-notifications.diff Review of attachment 9184651 [details] [diff] [review]: ----------------------------------------------------------------- This makes sense. I always wondered why using notifications was so wordy. There's implications for all add-ons with notifications. If this is going back to 78 (probably should?) I think every gNotification should have a shim notificationbox property to keep current add-on code working. By next ESR we should have an API sorted out so it wouldn't matter any more. r- just to counteract Magnus's r+. :-) ::: calendar/lightning/content/lightning-utils.js @@ +18,5 @@ > +XPCOMUtils.defineLazyGetter(this, "gNotification", () => { > + return new MozElements.NotificationBox(element => { > + document.getElementById("no-identity-notification").append(element); > + }); > +}); You don't want to add to `this` here, because this file is used in a bunch of different windows including the main window.
Attachment #9184651 - Flags: review?(philipp)
Attachment #9184651 - Flags: review?(geoff)
Attachment #9184651 - Flags: review-

We could do this for trunk only also. It's a problem, but not a huge one (unnoticed for over a year on release).

Attached patch 1673958-notifications.diff (obsolete) — Splinter Review

Thanks for the detailed review.
I updated all the notification variable to match what they actually area and what type of notification container they interact with. In this way, we won't have a bunch of random gNotification all around TB that we can't distinguish.

I also found other small CSS problems, and some wrong parameters we were passing when appending the notification (eg. "null" as a string instead of null).

If we decide to uplift this for 78, I prefer to create a patch variation with the shim variables, and keep trunk clean.

Try run to see how many things I broke: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=e8e45dd12e999ba636459c8caa540a796dab0147

Attachment #9184651 - Attachment is obsolete: true
Attachment #9188470 - Flags: review?(mkmelin+mozilla)
Attachment #9188470 - Flags: review?(geoff)
Comment on attachment 9188470 [details] [diff] [review] 1673958-notifications.diff Review of attachment 9188470 [details] [diff] [review]: ----------------------------------------------------------------- ::: calendar/lightning/content/lightning-item-iframe.js @@ +2647,1 @@ > if (notification != null) { would make this a falsy comparison while your're here
Attachment #9188470 - Flags: review?(mkmelin+mozilla) → review+
Attached patch 1673958-notifications.diff (obsolete) — Splinter Review

Patch updated and new try-run launched since the previous one picked the outdated build: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=b922a139914614fe455f44ed2d117455445c3659

Attachment #9188470 - Attachment is obsolete: true
Attachment #9188470 - Flags: review?(geoff)
Attachment #9188619 - Flags: review+
Attachment #9188619 - Flags: review?(geoff)
Attached patch 1673958-notifications.diff (obsolete) — Splinter Review

Patch updated to fix those bct3 failures.
Another try-run launched, which seems to be stuck: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=dc4284e1209cc1cd1b2a7967d9917cb65b4cfff1

I'll launch another one if this fails for whatever reason.
Ah, it's running, let's see if I broke something else.

Attachment #9188619 - Attachment is obsolete: true
Attachment #9188619 - Flags: review?(geoff)
Attachment #9188727 - Flags: review?(geoff)
Comment on attachment 9188727 [details] [diff] [review] 1673958-notifications.diff Review of attachment 9188727 [details] [diff] [review]: ----------------------------------------------------------------- ::: mail/components/im/content/chat-conversation-info.js @@ +113,5 @@ > > if (Services.prefs.getBoolPref("chat.otr.enable")) { > let otrButton = this.querySelector(".otr-button"); > otrButton.addEventListener("command", this.otrButtonClicked); > + OTRUI.setNotificationBox(gNotification); Do you still want to call this one gNotification? It's a bit confusing. ::: mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js @@ +3086,5 @@ > */ > async notifyUser(priority, msgText, messageId, detailsText) { > let notif = document.getElementById("attachmentNotificationBox"); > if (!notif) { > + notif = gNotification; This should be gComposeNotification, I think.
Attachment #9188727 - Flags: review?(geoff) → review+

Good catch, I missed those.
Also that Enigmail notifyUser() was using the wrong selector to attach a notification, so I fixed it.

Attachment #9188727 - Attachment is obsolete: true
Attachment #9189040 - Flags: review+

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/7b9df4584eda
Fix defective implementation of the MozElements.NotificationBox. r=mkmelin, r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED

Does TB78 need this? If yes, please request 84 beta approval.

Target Milestone: --- → 85 Branch

What do you think we should do Magnus? Beta ad 78 uplift?
We do risk to break add-ons using notifications in those areas.

Flags: needinfo?(mkmelin+mozilla)

It wasn't ever reported by user AFAIK, so maybe let it just ride the trains and skip uplifts.

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

Attachment

General

Created:
Updated:
Size: