3 Messages
•
254 Points
Lightroom Classic: Limit of 52 reorderings in custom-ordered collections and folders
[I've verified this bug still exists in LR 10.0. See this post. -- John Ellis]
After a while of custom sorting the order of photos and stacks within a collection (using Grid View), Lightroom starts to unpredictably refuse to sort photos. Some will get positioned where I drop them, others won't move at all and yet others will get positioned somewhere close by (eg. 4 or 5 photos before or after).
After digging into the catalog file I've come across what I think is the problem, but don't know how to fix it. In the attached file you'll see a screenshot of the database table for the collection, you'll see I've hilited the images that are part of the same collection, but their positionId is identical (which should never happen I'm assuming), probably due to the field size reaching it's maximum length. This is what I believe is causing the problem. Tested this on both Lightroom 5.7 and CC 2015.8.
This is a major bug and effectively stops user sorting from being functional, as well as now having potentially lost weeks of work. Any suggestions?
Thanks,
Adrian
Responses
Official Solution
John_R_Ellis
Champion
•
5.8K Messages
•
100.3K Points
4 m ago
The most recent bug recipe now works in LR 10.1. Let's hope that LR 10.1 also fixes the errors getting thrown by collections using custom sort order.
0
John_R_Ellis
Champion
•
5.8K Messages
•
100.3K Points
4 y ago
1. Create a collection with 3 photos.
2. Do View > Sort > Custom Order.
3. In the Collections panel, select the collection.
4. Drag the the third photo between the first and second photo.
5. Repeat the previous step 51 more times.
6. Now repeat step 4 one more time, and observe that the custom order doesn't change.
Thus, you can do 52 insertions after the first photo, but not 53.
A workaround:
1. After no more than 30 insertions after any one photo in a collection, select all of the photos in the collection.
2. Do Library > Create Collection.
3. Select "Include selected photos".
4. Delete the original collection.
5. Rename the new collection to have the original's name.
The new collection should have the same custom order as the original, and it will allow at least 30 insertions after any one photo before triggering the bug again.
ANALYSIS OF THE BUG
LR represents the custom-order position of a photo within a collection using a 64-bit floating point number. Initially, the photos have position values 1.0, 2.0, 3.0, etc. Suppose there are two adjacent photos A and B in the collection's custom order, and their positions are A.position and B.position. If you insert photo C between A and B, then:
C.position = (A.position + B.position) / 2
This might seem like a clever hack, allowing a photo to be inserted without reassigning the positions of the other photos in the collection. However, as seen above, it fails after a fixed number of insertions.
A 64-bit floating-point number uses 53 bits for representing the mantissa. If A.position is originally 1, and B.position is originally 2, then there are at most 52 bits available for representing the position between A and B. After 52 insertions, there are no more bits available for representing C.position. Note that if A.position is a larger number, say 1024 (2^10), then there will be only 43 bits available for representing the position between A and B (43 insertions).
The fix is straightforward: If A.postion = (A.position + B.position) / 2, then A.position has to be decreased a little or B.position increased a little to make room for C.position. In the extreme case, that might involve changing the .position of the photo preceding A or the photo following B, possibly rippling through the entire collection in the worst (but highly unlikely case).
What's the likelihood this will ever be fixed? Vanishingly small, in my opinion.
0
John_R_Ellis
Champion
•
5.8K Messages
•
100.3K Points
4 y ago
A clarification: If you are inserting more than one photo at a time, it will take far fewer than 52 insertions to trigger the bug. For example, if you are inserting 128 photos at a time, the bug will be triggered on the 8th insertion.
0
adrian_cleave
3 Messages
•
254 Points
4 y ago
I tried your workaround and it "almost" solves the problem. While it does keep the custom sort order and resets the "positionInCollection" number...the new collection doesn't unfortunately maintain Stack relationships. So my two scenarios are I either:
a) Select all images with Stacks Collapsed and then get a new collection with only the top image from the stack
b) Expand all Stacks, select all and create new collection, which ends up with the correct order but all stacks have been broken.
I'm using stacks to group duplicates/variations of a single photo and have >10,000 photos that I'm trying to sequence and group into stacks. So far it's proving very difficulty to actually achieve this due to this bug.
Any thoughts on how to tackle Stacks using the workaround would be greatly appreciated.
Thanks!
Adrian
1
0
John_R_Ellis
Champion
•
5.8K Messages
•
100.3K Points
4 y ago
The array "position" contains the custom-order positions that will be stored in the database column AgLibraryCollectionImage.positionInCollection. position[i] is the value of "positionInCollection" for the ith image in the collection (in custom order).
This code assumes that "nInserted" photos have been inserted at ordinal position "i + 1" though "i + nInserted" and there are a total of "nPhotos" in the collection.
The algorithm tries to minimize the number of entries in "position" that are changed (since those entries will be written back to the catalog database). It tests whether the inserted photos can be correctly assigned positions between position [i] and position [j] (without exceeding the precision of floating point numbers); if they can't, then i is repeatedly decreased by 1 or j increased by 1, alternatingly, until there is "room".
As special cases, a range of photos at the beginning or end of the collection order will be assigned integer-valued positions.
0
adrian_cleave
3 Messages
•
254 Points
4 y ago
STEPS:
1. Create tmp table with a unique, auto-increment col for order_id
2. Copy into tmp table from source with order by collection and position
3. Update the position back into source from tmp using order_id*100 for position (to buy extra re-orders)
SQLITE CODE:
CREATE TABLE IF NOT EXISTS "tmpTable" (
"order_id" integer PRIMARY KEY autoincrement,
"id_local" integer NOT NULL DEFAULT(0),
"collection" integer NOT NULL DEFAULT(0),
"positionInCollection"
);
INSERT INTO tmpTable(id_local, collection, positionInCollection)
SELECT id_local, collection, positionInCollection FROM AgLibraryCollectionImage ORDER BY collection DESC, positionInCollection ASC;
UPDATE AgLibraryCollectionImage
SET positionInCollection = (SELECT tmpTable.order_id
FROM tmpTable
WHERE tmpTable.id_local = AgLibraryCollectionImage.id_local)*100
WHERE
EXISTS (
SELECT *
FROM tmpTable
WHERE tmpTable.id_local = AgLibraryCollectionImage.id_local
);
DROP TABLE tmpTable;
0
carol_peterson_di5yasdh0duh2
10 Messages
•
172 Points
4 y ago
I'm now having a second drag and drop issue. I don't know if it's related, but here's what happens:
I begin by dragging individual photos, one by one, further up in the order on the grid. I'm doing this because when I scanned the photos, they were scanned in reverse order so I need to reorder them.
To do this, I select an image upwards on the grid to mark my insertion point. I then drag photos from below in the grid, and drop them in front of the selected photo. This works fine for a while, but after a number of drags and drops, the selected photo "freezes."
What I mean by this is, I am no longer able to drop photos in front of the selected photo--when I let go of the dragged photo, it actually lands behind the selected photo, even though I dropped it in front. At first I didn't realize this was happening and it really messed up the order of my photos!
Now that I see it happening, I can fix it: I drag the selected photo, and drop it behind the photos I recently moved up (that landed in the wrong spot). After I do that, everything is fixed, at least for a while. Then it randomly happens again.
It's clear to me there are some bugs in the drag and drop functionality of the Grid view. Perhaps this is not a typical use case for Lightroom. I'm a photo organizer, not a photographer. I take my clients' photos and organize them and add metadata. The order matters because often clients have a legend, at least for trip photos, that identify each image. I need them in the right order so they can be tagged correctly.
Many of my clients' photos are paper and must be scanned. And since the scanning process often gets them out of order, I have to reorder them manually--hence all the dragging and dropping.
Unfortunately there isn't anything I can screen grab of here, but hopefully I have captured the steps that cause the bug. Please let me know if I should move this to a new thread.
Note: This conversation was created from a reply on: Lightroom: After an unsuccessful drag of an image, dragging is no longer possible....
4
0
carol_peterson_di5yasdh0duh2
10 Messages
•
172 Points
4 y ago
My work around may be to reorder the photos in the file system folders before importing into LR and avoid the bug altogether.
I'm curious--if you are interested, follow the link to my other reordering issue in my post above. I'm wondering if the bogus error message I get is also related to this problem.
It is disheartening to hear Adobe is unlikely to fix this. It breaks work flow, and it sounds like it is potentially losing data if the db entries are messed up. That seems serious enough to deserve a fix.
2
0
sunil_bhaskaran
Adobe Administrator
•
538 Messages
•
9.9K Points
3 y ago
Could you please have a look and let us know?
Thanks,
Sunil
0
0
John_R_Ellis
Champion
•
5.8K Messages
•
100.3K Points
3 y ago
https://feedback.photoshop.com/photoshop_family/topics/lightroom-major-bug-with-custom-sort-order?to...
the first 52 insertions (drag of the third photo between the first and second) work correctly, but the 53rd insertion fails. But then subsequent insertions work correctly.
0
0
sunil_bhaskaran
Adobe Administrator
•
538 Messages
•
9.9K Points
3 y ago
Let us check again.
Thanks,
Sunil
0
0
matt_audette
1 Message
•
60 Points
3 y ago
0
0
sunil_bhaskaran
Adobe Administrator
•
538 Messages
•
9.9K Points
3 y ago
Could you please let us know what exactly the issue you are facing?
Thanks,
Sunil
0
0
John_R_Ellis
Champion
•
5.8K Messages
•
100.3K Points
2 y ago
This was reported fixed in 7.1, and I supposedly verified the fix (see above), so either the bug has resurfaced or my verification was mistaken.
* * *
Here's a dump of AgLibraryCollectionImage.positionInCollection after the 52nd insertion and then after the 53rd insertion. Notice that the positions of the 2nd and 3rd photo become identical after the 53rd insertion:
0
0
steven_hutner_3o08nui95cgjy
42 Messages
•
560 Points
2 y ago
Using the latest (12/12/2018) Lightroom CC classic 8.1, I am having problems with custom photo sort order. I have a folder that contains a number of JPG and RAW images from both my phone (Galaxy S7) and my SLR (Nikon D610). The images were sorted into a custom order with only the SLR photos in the folder prior to the 8.1 update.
Today I merged the camera photos into the folder which lead to the problem. (Also today I updated to the latest 8.1).
I cannot sort the JPG photos (by dragging them to a new location - they do not move). Also, if a SLR photo is between the JPG photos, I cannot move it either. The JPGs are all at the front of the album. I can move the SLR photos that are after all the JPG photos.
1
0