futurepress / epub.js

Enhanced eBooks in the browser.
http://futurepress.org
Other
6.3k stars 1.08k forks source link

Rendition.display sometimes doesn't show the correct CFI. #895

Open BrianSladek opened 5 years ago

BrianSladek commented 5 years ago

Once in a while, rendition.display will not display the correct location in the book. Usually, it will display a location one or two pages behind the correct location.

Steps to reproduce:

  1. Open this link in your browser (I'm using Chrome): https://futurepress.github.io/epubjs-reader/index.html?bookPath=https://s3.amazonaws.com/epubjs/books/alice.epub#epubcfi(/6/10[chapter_002]!/4/2/22/3:349)

  2. Notice the epubcfi in the link above. After the book finishes displaying, the epubcfi in the URL (and the one that is apparently being used to display the book) suddenly jumps to https://futurepress.github.io/epubjs-reader/index.html?bookPath=https://s3.amazonaws.com/epubjs/books/alice.epub#epubcfi(/6/10[chapter_002]!/4/2/16/1:0) which is one page behind.

  3. Flip to the next page of the book manually and then refresh the page and you'll be brought back to the previous page.

I'm not very clear on why this is happening based on the code in rendition.js. I am seeing this problem in my own implementation not using epubjs-reader. In my implementation, I call rendition.display with an EpubCFI and then I immediately receive the new, incorrect location from the rendition's locationChanged event.

alidbc commented 4 years ago

This issue is still appearing even after the potential fix mentioned above. It happens after refreshing the book. Without opening the book again it will page to the correct location