Extend the Tracking Database to ingest real time data from browser content.
Bug 2030052 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
The anti-tracking database (protections.sqlite, backed by TrackingDBService) today is only written to when a WindowGlobalParent is destroyed: i.e. when a page unloads or a tab closes (dom/ipc/WindowGlobalParent.cpp). Long-lived tabs (Gmail, YouTube, Discord, etc.) accumulate blocking events in ContentBlockingLog for hours or days and never flush them, so anything reading the database: the Protection Dashboard, milestone messaging, and the upcoming Android Global Protections Dashboard (Bug 2016140, Bug 2030080), sees stale data. We need to ingest tracking events from browser content in real time instead of waiting for page destruction. Proposed approach: - Add a periodic flush from ContentBlockingLog to TrackingDBService while the window is alive (timer-based, interval configurable via pref). - Also flush on visibility change (tab hidden / pagehide) so dashboards are fresh when the user switches away. - Make ContentBlockingLog::ReportLog() incremental — track a "last reported" cursor per LogEntry so repeated flushes don't double-count. Today Stringify() serializes the entire mLog. - Preserve existing exclusions: private browsing, non-top-level documents, and the browser.contentblocking.database.enabled pref. - Gate the new cadence behind a pref (e.g. browser.contentblocking.database.realtime.enabled + interval) so it can ship dark and be tuned.
The anti-tracking database (protections.sqlite, backed by TrackingDBService) today is only written to when a WindowGlobalParent is destroyed: i.e. when a page unloads or a tab closes (dom/ipc/WindowGlobalParent.cpp). Long-lived tabs (Gmail, YouTube, Discord, etc.) accumulate blocking events in ContentBlockingLog for hours or days and never flush them, so anything reading the database: the Protection Dashboard, milestone messaging, and the upcoming Android Global Protections Dashboard (Bug 2016140, Bug 2030080), sees stale data. We need to ingest tracking events from browser content in real time instead of waiting for page destruction. Proposed approach: - Add a periodic flush from ContentBlockingLog to TrackingDBService while the window is alive (timer-based, interval configurable via pref). - Also flush on visibility change (tab hidden / pagehide) so dashboards are fresh when the user switches away. - Make ContentBlockingLog::ReportLog() incremental — track a "last reported" cursor per LogEntry so repeated flushes don't double-count. Today Stringify() serializes the entire mLog. - Preserve existing exclusions: private browsing, non-top-level documents, and the browser.contentblocking.database.enabled pref. - Gate the new cadence behind a pref (e.g. browser.contentblocking.database.realtime.enabled + interval)
The anti-tracking database (protections.sqlite, backed by TrackingDBService) today is only written to when a WindowGlobalParent is destroyed: i.e. when a page unloads or a tab closes (dom/ipc/WindowGlobalParent.cpp). Long-lived tabs (Gmail, YouTube, Discord, etc.) accumulate blocking events in ContentBlockingLog for hours or days and never flush them, so anything reading the database: the Protection Dashboard, milestone messaging, and the upcoming Android Global Protections Dashboard (Bug 2016140, Bug 2030080), sees stale data. We need to ingest tracking events from browser content in real time instead of waiting for page destruction. Proposed approach: - Add a periodic flush from ContentBlockingLog to TrackingDBService while the window is alive (timer-based, interval configurable via pref). - Also flush on visibility change (tab hidden / pagehide) so dashboards are fresh when the user switches away. - Make ContentBlockingLog::ReportLog() incremental — track a "last reported" cursor per LogEntry so repeated flushes don't double-count. Today Stringify() serializes the entire mLog. - Preserve existing exclusions: private browsing, non-top-level documents, and the browser.contentblocking.database.enabled pref.