-
Notifications
You must be signed in to change notification settings - Fork 716
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
PDF renderer completion fixes #8937
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the edge case here for 2 pages? Seems like both 1 and 2 are edge cases, which seems odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought here is that the subsequent progress_delta fix might also fix this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, it would make sense that it was both 1 and 2, but I didn't have a PDF that was only 1 page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, no, that doesn't seem to fix it. When there are two pages in the pdf,
currentPage
seems to be constantly set to 1 becauseparseInt(this.currentLocation * this.totalPages)
always ends up at0
becausethis.currentLocation
doesn't get high enough.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm - my I am curious why that is specific to 2 page PDFs, and why on a 3 page PDF '2' does become a currentPage at some point, makes me think there might be something slightly off about our currentLocation calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this is just curiosity, not a blocker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello sir @rtibbles, I spent my time learning about the rendering of PDFs in Kolibri. I tried to understand the files
LearnImmersivelayout
,LearningActivityBar
,ProgressIcon
etc. If I am not wrong the PDFs are rendered here on a canvas. I have a doubt, about how can we track the current page from the rendered canvas? , I think if we get to know which page the user is at then we can fix theProgressIcon
not updating bug.(I will try to research more about PDF.js to understand this problem more)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't render every page at once (as this causes performance issues for larger PDFs) so we know which pages are currently rendered, and control that based on where the user is.
The component you linked to controls the rendering of a single page - it is then used inside a
RecycleList
component that handles only actually rendering the pages that are visible by the user at the current time: https://github.com/learningequality/kolibri/blob/develop/kolibri/plugins/pdf_viewer/assets/src/views/PdfRendererIndex.vue#L47It's in ^ this component that the progress tracking logic is happening, this is where the fix would almost certainly need to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rtibbles and @sairina, thanks for all your help I found a solution but I am not sure it is correct.
Let me explain what I came up with...
In the
<progressIcon>
we have a prop called "progress".The value of "progress" determines the state of
<progressIcon>
In React we use a hook
useEffect
which lets you perform side effects in function components (I am new to vue.js so I don't know what features we have in vue.js, we can use something like that).My Idea is when we scroll we can keep on updating the "progress" value maybe from the
PdfRendererIndex.vue
(not sure from where) something like:but I don't know how we can access the value of "this.progress" when we scroll
In the end when the "progress" value is equal to
1
. we can change theisComplete
value toTrue
andisInProgress
value toFalse
(I think, this part already exists in the code).Thank you for reading this, please tell me if wrong, I will search for another way to fix it. Or maybe it's just a small bug that I need to find and don't need all the stuff I mentioned above (sorry 😛)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, I never even considered looking at
ProgressIcon
! @rtibbles would probably know more about whether this is the right way to go in terms of efficiency, but if you want to explore it a bit more (if you haven't already):progress
is a prop, and its value is coming from thecontentProgress
prop in theLearningActivityBar
componentcontentProgress
is a computed prop coming fromcontentNodeProgress
in theLearnImmersiveLayout
componentuseContentNodeProgress.js
is where this is housed. It's called a composable, which is pretty similar to a React hook, you can see it in the code throughsetup()
and one of the difference between this and React hooks is that it is only run once (I believe).ProgressBar
and also in theLearnImmersiveLayout