VOOZH about

URL: https://phabricator.services.mozilla.com/D307080

⇱ ⚙ D307080 Bug 2047212 - Attribute the Android applink launch type to the pageload event by load id. r?kaya


Bug 2047212 - Attribute the Android applink launch type to the pageload event by load id. r?kaya
Needs ReviewPublic

Authored by acreskey on Tue, Jun 16, 5:05 PM.

Details

Reviewers
kaya
Bugzilla Bug ID
2047212
Summary

The pageload event moved to page destruction (bug 2042702), where the
BrowsingContext is discarded, so the applink launch type read from it was lost.
Store it parent-side keyed by load id at LoadURI and consume it when recorded.

Diff Detail

Repository
rFIREFOXAUTOLAND firefox-autoland
Branch
HEAD

Unit TestsBroken

TimeTest
0 mscode-review::general
WARNING: A generic error occurred in the code review bot.

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
Comment Actions

Summary of Changes

Intent

The bug addresses a regression where Fenix (Firefox for Android) cold start app-link navigation timing telemetry stopped reporting correctly. This happened because the pageload event was previously moved to fire at page destruction (bug 2042702), at which point the may already be discarded. Since the app-link launch type was stored on the , it was no longer available when the pageload event was actually recorded, causing the telemetry data to be lost.

Solution

The fix changes the storage mechanism for the Android app-link launch type from being stored on to a dedicated parent-process-side hash map keyed by load identifier.

New storage mechanism: A static is introduced in (behind ), along with two functions: to insert a launch type keyed by load id, and to retrieve and remove the stored value. Both operations are asserted to run on the main thread in the parent process.

Storing the launch type: In (parent-side), when a non-zero app-link launch type is present on the load state, it is now stored in this new map keyed by the load state's load identifier, instead of being set on the .

Capturing the load identifier in the document: During , the document now captures the load identifier from its into a new member . The itself stores the load identifier from the at the beginning of .

Sending the load identifier with the pageload event: The IPC message is updated to pass the load identifier instead of a . When the document is destroyed and fires, it sends the captured load identifier.

Consuming the launch type on the parent: In , the stored app-link launch type is retrieved (and removed) from the map using the load identifier, then passed directly to . This eliminates the need to look up the and the risk of it being discarded.

Cleanup of old approach: The field, its getter/setter, and the transfer logic during BC replacement (COOP swaps) are all removed from , as they are no longer needed.


Please use / reactions on inline comments to provide feedback. This will have a significant impact on the quality of future reviews.
dom/ipc/ContentParent.cpp
6419

The old code guarded this with , preventing a compromised content process from consuming app-link telemetry belonging to another process's load. The new code allows any child process to pass any and consume the corresponding stored launch type, which could corrupt telemetry data. Worth noting whether this loss of validation is acceptable.

tools/performance/PageloadEvent.cpp
39

The static hash map entries are never cleaned up if a navigation is cancelled, fails, or the content process crashes before the pageload event is submitted at document destruction. Each orphaned entry is small (12 bytes), but over a long-running session this is an unbounded leak. Add a mechanism to clean up stale entries—for example, remove the entry when the associated with the load identifier is destroyed without completing, or add an expiry/eviction policy.

acreskey added inline comments.
tools/performance/PageloadEvent.cpp
39

Given that we're only storing an entry, for navigations that failed this seems pretty minor to me.
i.e. it would be better to keep a simple hash table rather than a queue with an eviction policy or else plumbing to DocumentLoadListener to clear.

acreskey added inline comments.
dom/ipc/ContentParent.cpp
6419

The launch type is one field in an otherwise entirely content-populated telemetry event, so a compromised content process can already corrupt this ping.

Revision Contents

PathSize
docshell/
base/
11 lines
15 lines
6 lines
6 lines
4 lines
dom/
base/
4 lines
8 lines
ipc/
6 lines
31 lines
2 lines
tools/
performance/
11 lines
22 lines
CommitTreeParentsAuthorSummaryDate
03be9410847ff034e50b891a1d85bc4044b2acreskeyMoz
Bug 2047212 - Attribute the Android applink launch type to the pageload event… (Show More…)
Sat, Jun 13, 1:17 PM

Diff 1301477

docshell/base/BrowsingContext.cpp

Loading...

docshell/base/CanonicalBrowsingContext.h

Loading...

docshell/base/CanonicalBrowsingContext.cpp

Loading...

docshell/base/nsDocShell.h

Loading...

docshell/base/nsDocShell.cpp

Loading...

dom/base/Document.h

Loading...

dom/base/Document.cpp

Loading...

dom/ipc/ContentParent.h

Loading...

dom/ipc/ContentParent.cpp

Loading...

dom/ipc/PContent.ipdl

Loading...

tools/performance/PageloadEvent.h

Loading...

tools/performance/PageloadEvent.cpp

Loading...