Closed Bug 2073326 Opened 2 months ago Closed 1 month ago

[HNT] Starting new private tab from tabstray doesn't always create notification

Categories

(Firefox for Android :: Homepage, defect)

All
Android
defect

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed
firefox161 --- verified

People

(Reporter: tcampbell, Assigned: npoon)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxdroid] [group5])

Attachments

(1 file, 1 external file)

This one is intermittent and I haven't been able to get a video yet.

When I open first private tab from tab tray, I'll see a tabcount of 1 but sometimes the notification doesn't appear. Without HNT, the notification would not appear until we create first tab but in this case we did create the tab and it isn't show. Some sort of race condition likely.

Ah, this seems to be related to Android deferring notifications in some cases: https://developer.android.com/about/versions/12/behavior-changes-all#foreground-service-notification-delay

If I wait 10 seconds, the notification eventually appears. There seems to be some sort of NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE escape hatch that might work.

AbstractPrivateNotificationService.kt builds the foreground-service notification without setForegroundServiceBehavior(FOREGROUND_SERVICE_IMMEDIATE), and the browsing-session channel is IMPORTANCE_LOW with lights and vibration disabled and no notification actions (#255-260), so the notification matches none of the exemptions from the Android 12+ 10-second display deferral you linked. HNT only changes when the first private tab is created, which is what makes the deferral visible.

Fix: Add .setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE) to the builder chain in createNotification(), the way ProfilerService.kt already does for the profiler notification, and extend AbstractPrivateNotificationServiceTest.kt, which already captures the notification passed to startForeground, to assert the behavior field.

Suggested severity: S3. The notification is the only way to erase private tabs from outside the app and it is absent for up to 10 seconds after the first private tab opens, but it does arrive on its own without user action.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-wrong-file, ai-triage-wrong-cause, ai-triage-hallucination, ai-triage-out-of-scope, ai-triage-wrong-fix, ai-triage-shallow-fix.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

Severity: -- → S3
Whiteboard: [fxdroid] [group5]
Assignee: nobody → npoon
Status: NEW → ASSIGNED
Pushed by npoon@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e256f25f6021 https://hg.mozilla.org/integration/autoland/rev/fa54130fd878 Show private tab notification immediately when a new private tab is made r=p--xyhgnc68hvgie4h4sae9tk
Flags: qe-verify+
See Also: → 2084774
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

Verified as fixed on the latest Nightly 161.0a1 from 26.10.2026 with Pixel 7 PRO (Android 17) and Samsung S25 (Android 15).

Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: