-
-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed a bug causing duplicate object IDs #788
Conversation
The ID values for new "Selection" objects were being generated by the line "String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now()", which led to the Auto-detection feature frequently skipping pages in large documents. The unique IDs are now simply generated by converting Math.random() to a string.
Thank you for your contribution! I'm excited that this may fix the problem you describe. This mechanism for the problem is very interesting... Do you know why the previous version was creating collision for the IDs? |
Hi Jeremy! The previous code was generating IDs by concatenating a single random alphabetical character together with the system time in milliseconds, so when multiple pages were being processed in less than a millisecond, there was a probability that two pages would have identical IDs. The bug is easy to replicate; load up a sufficiently large document (in the several hundred pages range), use the "Repeat this selection" or Autodetect feature, and when you scroll through the document a small number of pages will be missing selections. I was processing 300-page long medicare fee schedule PDFs when I first encountered the issue, but any long document does the trick (https://www.novitas-solutions.com/webcenter/portal/MedicareJH/FeeLookup if you want some easy test material). |
Ah, that makes sense. Thank you again for digging into this and submitting the pull request! This may fix #780. |
@jazzido do you remember if there's any reason we chose to do a single random letter plus a timestamp for these IDs? Or more precisely, is there a reason to add any of that back in addition to the larger random number IDs suggested here? |
No idea. In any case, |
Haha, okay cool. Thanks again @willswope! |
@jeremybmerrill I'm glad I was able to help! Thank you for working on such a great project; it's saved me many hours of work. |
Fixed a bug causing duplicate object IDs
The ID values for new "Selection" objects were being generated by the line "String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now()", which led to the Auto-detection feature frequently skipping pages in large documents. The unique IDs are now simply generated by converting Math.random() to a string.