Repository navigation
Fix Location Stack Issues - #13607
Conversation
util.tableDeepCopy always returns a table
it can pe passed a nil / empty table if the location stack is empty, return early in this case. Fixes: koreader#12869
… get modified Fixes: koreader#13570
|
Indeed, I confirm I couldn't reproduce the crashes reported in #12869 and the 2 issues mentioned in #13570 after applying these fixes. Thank you! However, on the topic of location stacks there is another issue that's been bugging me that appears to affect all engines/view modes equally, and it happens to be my typical use case for the location stacks (and I imagine most other users' as well): Let's say I'm reading something at page 50, then skip to the back of the book to the notes (say page 270), then go back to page 50, continue reading, and then I want to go forward to the notes again. This works as long as I stay on page 50, but as soon as I turn the page forward (51) or backward (49), then |
|
Hard to explain in words, but a visualization might help.
Being as Page 40 is on the Forward stack if you now change to next page 41, Back is 20 but Forward is 40. This allows for: 4A. Back to previous So if we go forward now, we get to 40 (current page is transparently skipped). This is only possible because 40 was put on the forward stack in step 3. But we also get: They way to fix this is to complicate the location stack implementation and add a 3rd stack that only can have one entry Current stack, and lets play the steps again: C 20 P . F . C .
Even if you now change to next page 41, 4A. Back to previous This works but requires more overhead and calculations compared to the current simpler approach (and i am not sure it won't break other workflows / code), so am not going to PR for now, but open to comments / ideas |
|
Sorry for bad formatting due to mobile |
|
Thanks @yparitcher - I put the steps in table below for easier comparison. (I changed the ordering in the stacks so that the numbers are in the order they would come up if the action is called by the user, from LTR): Status quo:
How I would expect the stacks to work (without needing a 3rd stack):
Of course it's possible that I'm missing something, and I'm happy to move the discussion elsewhere (e.g., back to issue #13570, or a new issue). The most important thing is that the crashes are being fixed with this PR :) |
|
I edited / fixed your status quo table. |
|
Currently after step 3, if page 40 is not on the current location stack it breaks step 4a. |
I also corrected the bottom table for 4C |
|
For more details and motovation see #10228 where i implemented the forward stack |
I think there is a misunderstanding in the way to read the table. I just tested it again and the current location is only added to the fwd stack after the page turn. The 3rd column is prior to the action in column 4. |
|
We add the current location to the forward stack when going back. So after step 3. We have 40 & 60 on the forward stack. |
|
OK, I see what you mean. I built the table from a UX perspective; with regard to which locations the Reader UI jumps to when the back/forward actions are triggered, not with what is happening behind the scenes not discernible by the user. The Back/Forward link functions bypass the page if it is the same as current page the reader is on, that's why it appears that it is only added on the next step. But I can see where the confusion came from and could have made my intent clearer. Anyway, I don't want to unneccesarily delay this PR. I'd like to study the original PR you linked to and your comments and suggestions for an alternative approach, and then get back with a better informed opinion. |
Closes: #13570
Closes: #12869
Closes: #11989
Supersedes: #13560
@jonnyl2
The crash is fixed by the second commit (reproduced and tested), the nil check is enough, please confirm.
The issues in #13570 are fixed by the second commit, i reproduced and tested with the first issue there, but it should fix the second also, please confirm
This change is