Open a 400-page manual in a browser and you want to read page one, not wait for page four hundred. Until this summer, the Fernquill portal made you wait longer than it had to.
Opening a document did three things before the first page appeared: it read the whole cross-reference table, it measured every page, and it built the text index for search. On a large file the second step alone took more than a second.
None of that is needed to draw one page. The viewer needs the size of the pages it shows, and the size of the rest only roughly, to lay out the scroll bar.
The engine now reads page sizes on demand. The first screen asks for a handful of pages; the rest are measured in the background, a few hundred at a time, while the reader is already looking at the document.
Until a page is measured, the layout uses the size of its neighbours. Most documents use one page size throughout, so the guess is almost always right, and when it isn't, the view stays on the page the reader is looking at while the pages above it settle.
The cross-reference table is still read in full, because a damaged file can only be repaired from all of it. But it's read once, and both the measuring and the drawing share it.
The text index moved off the opening path as well. It's built the first time someone searches, page by page, and the results come in as each page is done. Most people who open a document never search it, and they no longer pay for the index.
The time until the first page shows, on a mid-range laptop, before and after the change:
| Document | Pages | Before | After |
|---|---|---|---|
| Product manual | 412 | 1,840 ms | 590 ms |
| Annual report | 168 | 920 ms | 330 ms |
| Contract | 24 | 210 ms | 160 ms |
Small documents gain little, because there was little to skip. The larger the file, the more the change matters.
The same idea comes to thumbnails: a sidebar with a thousand pages should only draw the ones on screen, and measure the rest as it scrolls.