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.
Yup, that's definitely happening on nightly.
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.
(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.