Bookmark ordering is potentially inconsistent in presence of Sync

NEW
Unassigned

Status

()

Firefox for Android
Data Providers
24 days ago
8 days ago

People

(Reporter: Riley Sunshine, Unassigned)

Tracking

Firefox 56
Points:
---

Firefox Tracking Flags

(firefox57 affected, firefox58 affected, firefox59 affected)

Details

Attachments

(1 attachment)

(Reporter)

Description

24 days ago
Created attachment 8923204 [details]
Bookmark Position Value Negative Int.png

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0
Build ID: 20171024165158

Steps to reproduce:

Added new bookmark using the bookmark buttons.
Using: Firefox version 56.0.
Using: Android 7.1


Actual results:

New entry was added in browser.db with incorrect position value. First new bookmark's value is 0, next new bookmarks position value was -9223372036854775808.


Expected results:

Value should have been current maximum value + 1.
Component: Profile Handling → Data Providers

Comment 1

8 days ago
Yup, that's definitely happening on nightly.
Status: UNCONFIRMED → NEW
Ever confirmed: true

Updated

8 days ago
status-firefox57: --- → affected
status-firefox58: --- → affected
status-firefox59: --- → affected

Comment 2

8 days ago
This logic is a bit awkward, and as a result there are some minor UI inconsistencies.

We create bookmarks with a default position of Integer.MIN_VALUE. During a bookmark sync, positions are "normalized" (reset to 0, or to whatever else Sync deems necessary, depending on bookmark reconciliation and other clients).

Without a sync, it doesn't seem to me like we'd reset the position to something other Integer.MIN_VALUE.

Our default sort order for bookmarks is "type ASC, position ASC, _id ASC".

Without sync, for a regular bookmark "type" and "position" will remain constant, so we're really just ordering by "_id ASC".

New bookmarks go to the top of the list, but after all the other "new" bookmarks. Thus for a user that never used sync, they'll see bookmarks appear at the bottom of their bookmarks list.

For a sync user, however, they'll see new bookmarks appear at the top of the bookmarks list, but after any bookmarks that haven't been synced yet.
Summary: New Bookmarks Are Saving As Negative Integers in browser.db → Bookmark ordering is potentially inconsistent in presence of Sync
(In reply to :Grisha Kruglov from comment #2)

> Without a sync, it doesn't seem to me like we'd reset the position to
> something other Integer.MIN_VALUE.

Yes, this was intentional. Even when we added this code (Bug 704490 Comment 39!), Fennec showed bookmarks alphabetically. The position was added for the benefit of Sync (which needs to track folder contents over time), not the frontend.


> For a sync user, however, they'll see new bookmarks appear at the top of the
> bookmarks list, but after any bookmarks that haven't been synced yet.

If you want to change this, the easy option is to ORDER BY … abs(position) ASC …. That will sort all of the new local bookmarks to the end.
You need to log in before you can comment on or make changes to this bug.