Skip to content
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

Resource cache (Blob URIs) algorithm incorrect: downshiftedEntry.orderingByLastUseTimestampIdx #104

Open
danielweck opened this issue May 20, 2015 · 3 comments

Comments

@danielweck
Copy link
Member

Cloud reader, Chrome web browser, on Windows 8.1

To reproduce, navigate (using the TOC) several pages / spine items in SmokeTestFXL.

"algorithm incorrect: downshiftedEntry.orderingByLastUseTimestampIdx"

This assertion error occurs when ResourceCache.getResourceURL() is invoked.

https://github.com/readium/readium-js/blob/master/epub-modules/epub-fetch/src/models/resource_cache.js#L68

            function removeCacheEntryFromOrderedIndex(cacheEntry) {
                // Remove the previous entry from the ordered index, if present:
                if (typeof cacheEntry.orderingByLastUseTimestampIdx !== 'undefined') {
                    var orderingByLastUseTimestampIdx = cacheEntry.orderingByLastUseTimestampIdx;
                    _orderingByLastUseTimestamp.splice(orderingByLastUseTimestampIdx, 1);
                    // Decrement index values for all downshifted entries:
                    for (var i = orderingByLastUseTimestampIdx; i < _orderingByLastUseTimestamp.length; i++) {
                        var downshiftedEntry = _orderingByLastUseTimestamp[i];
                        // Assertion
                        if ((downshiftedEntry.orderingByLastUseTimestampIdx - 1) != i) {
                            console.error('algorithm incorrect: downshiftedEntry.orderingByLastUseTimestampIdx: ' +
                                downshiftedEntry.orderingByLastUseTimestampIdx + ', i: ' + i);
                        }
                        downshiftedEntry.orderingByLastUseTimestampIdx = i;
                    }
                }
            }
@danielweck
Copy link
Member Author

Note: Blob URIs are used to populate linked resources in parsed HTML spine items and CSS files, only in the case of "programmatic fetching" (i.e. direct zipped EPUB loading, or obfuscated fonts in expanded EPUBs).

@danielweck
Copy link
Member Author

I wonder if this has anything to do with premature _publicationResourcesCache.unPinResources() in a two-page synthetic spread (fixed layout => 2x spine items):

https://github.com/readium/readium-js/blob/develop/epub-modules/epub-fetch/src/models/publication_fetcher.js#L131

@friedolinfoerder
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants