Closed Bug 1489053 Opened 3 years ago Closed 3 years ago

The CFR "frecency" score value is inconsistent when accessing a website from different locations

Categories

(Firefox :: Messaging System, defect)

Unspecified
All
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox62 --- unaffected
firefox63 --- affected
firefox64 --- affected

People

(Reporter: mcoman, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached image rec of the issue.gif
[Affected versions]:
- Firefox 63 and above

[Affected Platforms]:
- All Windows
- All Linux
- All Mac

[Prerequisites]:
- Have a Firefox profile with the following prefs in the "about:config" page:
	- "browser.newtabpage.activity-stream.asrouterExperimentEnabled" with "true" value;
	- "browser.search.region" with "US" value.
	-  "devtools.chrome.enabled" on true.
- Have the "Browser Console" opened.

[Steps to reproduce]:
1. Open the browser with the profile from prerequisites.
2. Open a new tab and navigate to the "facebook.com" website from the "Address Bar".
3. Repeat step 2 for another 4 times and focus the "Browser Console".
4. Enter the following string in the console: "NewTabUtils.activityStreamProvider.getTopFrecentSites({numItems: 25}).then(r => console.log(r.map(s=>`${s.url} [${s.frecency}]`).join('\n')))".
5. Observe the displayed "frecency".

[Expected result]:
- The "frecency" score is more or equal to "10000"

[Actual result]:
- The "frecency" score is "2350".

[Notes]:
- The correct "frecency" score (10000) is generated when following the same steps as above, but instead opening the Facebook website from the "Top Sites" area.
- This issue is also reproducible with the other websites.
- Attached a screen recording of the issue.
This is a bit of a weird bug. It seems to stem from the fact that you're typing 'facebook.com' into the url bar which results in a (permanent) redirect to 'www.facebook.com'. Clicking through from the new tab page takes you straight to 'www.facebook.com' without being redirected.

The first few times you type 'facebook.com' into the awesome bar and hit enter you will visit 'facebook.com' and hit the redirect. In my testing, after several minutes/visits, the awesome bar registers that the permanent redirect exists and from then on when you type in 'facebook.com' and hit enter it will actually take you straight to 'www.facebook.com', without hitting the redirect.

This affected the frecency scores.

When you visit 'facebook.com' and get redirected to 'www.facebook.com' both urls get some added frecency. 'facebook.com' gets the "RedirectSourceVisit" bonus which is 25. 'www.facebook.com' gets the "PermRedirectVisit" bonus which is 50. If you visit a url directly from the awesome bar and there's no redirect, you get the "TypedVisit" bonus which is 2000. Unfortunately in this case the redirect overrides the "TypedVisit" [0]. A further complication is that 'activityStreamProvider.getTopFrecentSites' combines the frecency scores for 'facebook.com' and 'www.facebook.com' by default, and that's what you see printed to the console [1]. So the net effect is adding 75 frecency overall.

Once the permenant redirect is registered by the awesomebar (which happens pretty quickly) and it starts taking you straight to 'www.facebook.com' then the issue goes away because you get the correct 2000 "TypedVisit" frecency bonus.

[0] https://searchfox.org/mozilla-central/rev/de7676288a78b70d2b9927c79493adbf294faad5/toolkit/components/places/nsNavHistory.h#343

[1] You can see them split up with "NewTabUtils.activityStreamProvider.getTopFrecentSites({numItems: 25, onePerDomain: false}).then(r => console.log(r.map(s=>`${s.url} [${s.frecency}]`).join('\n')))"
The frecency algorithm works in mysterious ways :-)

CFR is simply using the existing frecency algorithm as a proxy for sites that are 'important to the user'.  We aren't interested in improving/modifying/changing the frecency algorithm, we just want to use it to prevent adding additional placesdb queries.

Let's acknowledge that this makes it difficult to test and work on adding a history targeting mechanism to CFR that doesn't rely on frecency.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WONTFIX
Component: Activity Streams: Newtab → Messaging System
You need to log in before you can comment on or make changes to this bug.