Closed Bug 1948339 Opened 1 month ago Closed 5 days ago

Add NotificationObserver to keep handlers alive for backends without persistence support

Categories

(Core :: DOM: Notifications, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: saschanaz, Assigned: saschanaz)

References

(Blocks 3 open bugs)

Details

Attachments

(2 files)

Currently Firefox closes push notifications when either the page or service worker goes away on Linux and macOS. We should keep them alive at least until Firefox process is closed, and for that there should be an entity that can outlive PNotification.

(Keeping handlers registered regardless of PNotification lifecycle would let notifications alive, but Alert Service alone can't and shouldn't handle service workers)

Mostly became redundant after IPC migration or even before that.

Attachment #9470313 - Attachment description: WIP: Bug 1948339 - Part 2: Add NotificationObserver → Bug 1948339 - Part 2: Add NotificationObserver r=asuth
Summary: Add NotificationManager to keep handlers alive for backends without persistence support → Add NotificationObserver to keep handlers alive for backends without persistence support
Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/50816653be46 Part 1: Clean up unused header inclusion r=asuth
Status: NEW → RESOLVED
Closed: 15 days ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch

Backed out for causing leaks @ browser/browser.toml

Status: RESOLVED → REOPENED
Flags: needinfo?(krosylight)
Resolution: FIXED → ---
Target Milestone: 138 Branch → ---

macOS specific because Windows and Linux counterparts listen to quit-application and clean things up. This should probably be done by nsAlertsService than on each system service.

(But technically it should be an existing problem)

Flags: needinfo?(krosylight)

So bug 1953906 can fix the issue in comment #7, but the real implication here is that the observer holds nsIPrincipal forever until the notification closes. That sounds bad, and maybe PrincipalInfo can be used to not do that? Thoughts?

Flags: needinfo?(bugmail)

We want to get rid of PrincipalInfo in favor of only ever holding nsIPrincipals. I hadn't appreciated that we might not be properly handling shutdown for notifications since that was more on the toolkit side from my perspective, but we should be handling shutdown.

Flags: needinfo?(bugmail)

Sure we should handle shutdown, but shouldn't we also prevent holding principals too long? Especially when holding principal also means holding windows and potentially make another ghost window issue.

(In reply to Kagami Rosylight [:saschanaz] (they/them) from comment #13)

Sure we should handle shutdown, but shouldn't we also prevent holding principals too long? Especially when holding principal also means holding windows and potentially make another ghost window issue.

Can you elaborate on the ownership chain you are describing as it relates to comment 7, in particular if you're referring to a specific log and specific contents in it if you could provide a log viewer URL with the lines selected? If I look at the fields in ContentPrincipal I see how we can entrain atoms but I don't see how we can entrain windows. (That said there obviously are ways for a DOM binding that's not a GlobalTeardownObserver but depends on CC and could be part of a non-CC'ed graph if the observer service is also holding a strong ref.)

Flags: needinfo?(krosylight)

Per https://treeherder.mozilla.org/logviewer?job_id=498742864&repo=autoland&lineNumber=28189 it leaks dom/notification/test/browser/empty.html which the affected test uses, which IMO should not happen even if the observer leaks, as the observer should not hold the window in any way. It's unclear to me how that can happen either.

Flags: needinfo?(krosylight)

But perhaps that's just a red herring? 🤔

Per the private chat with :asuth, it seems the leak is because of the observer being XPConnect wrapper and thus references JSRuntime. I'd have never imagined that, thanks Andrew!

Status: REOPENED → RESOLVED
Closed: 15 days ago5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: