{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/5655","labels_url":"https://api.github.com/repos/mozilla/pdf.js/issues/5655/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/pdf.js/issues/5655/comments","events_url":"https://api.github.com/repos/mozilla/pdf.js/issues/5655/events","html_url":"https://github.com/mozilla/pdf.js/pull/5655","id":54660366,"number":5655,"title":"Avoid getting stuck in empty nodes in the Pages tree when calling |Catalog_getPageDict| (issue 5644)","user":{"login":"Snuffleupagus","id":2692120,"avatar_url":"https://avatars.githubusercontent.com/u/2692120?v=3","gravatar_id":"","url":"https://api.github.com/users/Snuffleupagus","html_url":"https://github.com/Snuffleupagus","followers_url":"https://api.github.com/users/Snuffleupagus/followers","following_url":"https://api.github.com/users/Snuffleupagus/following{/other_user}","gists_url":"https://api.github.com/users/Snuffleupagus/gists{/gist_id}","starred_url":"https://api.github.com/users/Snuffleupagus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Snuffleupagus/subscriptions","organizations_url":"https://api.github.com/users/Snuffleupagus/orgs","repos_url":"https://api.github.com/users/Snuffleupagus/repos","events_url":"https://api.github.com/users/Snuffleupagus/events{/privacy}","received_events_url":"https://api.github.com/users/Snuffleupagus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mozilla/pdf.js/labels/1-core","name":"1-core","color":"DDDDDD"}],"state":"open","locked":false,"assignee":{"login":"brendandahl","id":942640,"avatar_url":"https://avatars.githubusercontent.com/u/942640?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandahl","html_url":"https://github.com/brendandahl","followers_url":"https://api.github.com/users/brendandahl/followers","following_url":"https://api.github.com/users/brendandahl/following{/other_user}","gists_url":"https://api.github.com/users/brendandahl/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandahl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandahl/subscriptions","organizations_url":"https://api.github.com/users/brendandahl/orgs","repos_url":"https://api.github.com/users/brendandahl/repos","events_url":"https://api.github.com/users/brendandahl/events{/privacy}","received_events_url":"https://api.github.com/users/brendandahl/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mozilla/pdf.js/milestones/16","html_url":"https://github.com/mozilla/pdf.js/milestones/2015%20Q1","labels_url":"https://api.github.com/repos/mozilla/pdf.js/milestones/16/labels","id":924055,"number":16,"title":"2015 Q1","description":"- B2G Viewer refactoring\r\n- Regressions","creator":{"login":"yurydelendik","id":1523410,"avatar_url":"https://avatars.githubusercontent.com/u/1523410?v=3","gravatar_id":"","url":"https://api.github.com/users/yurydelendik","html_url":"https://github.com/yurydelendik","followers_url":"https://api.github.com/users/yurydelendik/followers","following_url":"https://api.github.com/users/yurydelendik/following{/other_user}","gists_url":"https://api.github.com/users/yurydelendik/gists{/gist_id}","starred_url":"https://api.github.com/users/yurydelendik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yurydelendik/subscriptions","organizations_url":"https://api.github.com/users/yurydelendik/orgs","repos_url":"https://api.github.com/users/yurydelendik/repos","events_url":"https://api.github.com/users/yurydelendik/events{/privacy}","received_events_url":"https://api.github.com/users/yurydelendik/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":20,"state":"closed","created_at":"2015-01-06T16:46:42Z","updated_at":"2015-04-09T21:38:37Z","due_on":"2015-03-30T22:00:00Z","closed_at":"2015-04-09T21:38:37Z"},"comments":10,"created_at":"2015-01-17T12:26:40Z","updated_at":"2015-04-17T22:42:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla/pdf.js/pulls/5655","html_url":"https://github.com/mozilla/pdf.js/pull/5655","diff_url":"https://github.com/mozilla/pdf.js/pull/5655.diff","patch_url":"https://github.com/mozilla/pdf.js/pull/5655.patch"},"body":"This is a tentative patch that fixes #5644.\r\n\r\nThe issue with the referenced PDF file is that the `Pages` dictionary contains a number of empty `Kids`, and we were getting stuck in those nodes before reaching the actual pages.\r\n\r\n~~As far as I can tell [this code is just an optimization](https://github.com/mozilla/pdf.js/blob/master/src/core/obj.js#L636), to avoid what is usually a number of unnecessary iterations, but isn't strictly necessary. The only way I could find to solve the particular issue referenced, and to avoid similar issues in the future, was to remove that code path. This might mean that the lookup becomes a *tiny* bit slower in very large files, but I unfortunately found no other way to fix the issue (hence why I'm labelling this as a tentative patch).~~\r\n\r\n**Edit:** Removing [this optimization](https://github.com/mozilla/pdf.js/blob/master/src/core/obj.js#L636), as the first version of the patch did, would be bad for performance reasons (especially with ranged loading). Hence I've submitted a new, and hopefully better, version of the patch that only checks all `Kids` if we've actually encountered an empty node.\r\n\r\nI've checked a large number of the PDF files in the test suite, especially the longer ones (where the performance penalty would be especially bad), and didn't find any file where the special case introduced in this patch was actually hit.\r\n\r\n*Note:* I'm adding an `eq` test, to ensure that we actually find the *correct* page for each `pageIndex`."},"comment":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/comments/94090443","html_url":"https://github.com/mozilla/pdf.js/pull/5655#issuecomment-94090443","issue_url":"https://api.github.com/repos/mozilla/pdf.js/issues/5655","id":94090443,"user":{"login":"pdfjsbot","id":1036361,"avatar_url":"https://avatars.githubusercontent.com/u/1036361?v=3","gravatar_id":"","url":"https://api.github.com/users/pdfjsbot","html_url":"https://github.com/pdfjsbot","followers_url":"https://api.github.com/users/pdfjsbot/followers","following_url":"https://api.github.com/users/pdfjsbot/following{/other_user}","gists_url":"https://api.github.com/users/pdfjsbot/gists{/gist_id}","starred_url":"https://api.github.com/users/pdfjsbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdfjsbot/subscriptions","organizations_url":"https://api.github.com/users/pdfjsbot/orgs","repos_url":"https://api.github.com/users/pdfjsbot/repos","events_url":"https://api.github.com/users/pdfjsbot/events{/privacy}","received_events_url":"https://api.github.com/users/pdfjsbot/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T22:42:07Z","updated_at":"2015-04-17T22:42:07Z","body":"#### From: Bot.io (Linux)\n\n----\n\n# Success\n\nFull output at http://107.21.233.14:8877/352f1b0cbaa9d80/output.txt\n\nTotal script time: 22.72 mins\n\n+ **Lint:** Passed\n+ **Make references:** Passed\n+ **Check references:** Passed"}}