Resource cache (Blob URIs) algorithm incorrect: downshiftedEntry.orderingByLastUseTimestampIdx
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;
}
}
}
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).
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
+1