-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
total is undefined in LoadingTask.onProgress #9103
Comments
Is this Chrome-specific? In Firefox I get the following output, which looks good:
|
It's related to |
@timvandermeij , Can I try this issue ? |
Since this issue can be observed in two different browsers, are we sure that this isn't a problem with the Fetch standard[1] itself? [1] This looks like the relevant part of the specification: https://fetch.spec.whatwg.org/#terminology-headers |
Basically while using the Line 427 in 237bc2e
and while using Chrome browser, total is defined in this way because it uses the fetch_stream pdf.js/src/display/fetch_stream.js Line 152 in 237bc2e
So basically this._contentLength is undefined in both cases but in the first case data.total contains the total count so it doesn't cause a problem. So we can try to do something similar in the second case too.
Shall I give this a try ? |
In |
@mukulmishra18 , ok let me look into this. |
@mukulmishra18 , could you explain when is the pdf.js/src/display/fetch_stream.js Line 34 in 237bc2e
source passed. As source.length turns out to be undefined
|
First we are setting Lines 35 to 45 in 237bc2e
based on the environment and support for stream. So if streaming is supported by the browser then After this we are calling this constructor with all the provided Line 255 in 237bc2e
If you want to see what these Lines 98 to 140 in 237bc2e
|
@mukulmishra18 , Thanks for all this explanation and now I can understand things better.
But when I debugged this I found out that in both the cases i.e. be it Line 433 in fad2a3f
In this line data.total contains the value of total size
Line 142 in fad2a3f
In this line evt is actually the data object used above. So should I try doing something like this in the fetchStream case too.Or Can you suggest me something ? Because I can see that @Snuffleupagus was right on this as I think this is a fetch API limitation |
I will suggest you to create a simple PDF.js app and try to run in Chrome and check if you are getting right headers(especially pdf.js/src/display/fetch_stream.js Line 106 in 237bc2e
I also think it may be a problem of fetch standard or browser as mentioned in #9103 (comment). If that is the case, we can't do a lot in PDF.js to fix this. |
I have been using the app all the time, mentioned in #9103 (comment)
That's what I'm trying to say that I can't find the |
FYI, pdf.js/src/display/fetch_stream.js Lines 104 to 115 in 6b7e2cb
and the value originates from pdf.js/src/display/network_utils.js Lines 42 to 47 in 6b7e2cb
But this value is guarded behind range requests. Before the above snippet, the function returns early if pdf.js/src/display/network_utils.js Lines 23 to 42 in 6b7e2cb
I don't see an immediate reason for blocking that, so perhaps it makes sense to unconditionally use the value of the |
Hi! My first comment in GitHub, sorry if I make a mistake. So I did: returnValues.suggestedLength = length ; , Also the Http header must match, so attention with Content-Length and Content-length (case sensitive) |
We just updated to 1.10.97 which broke our loading task. As a (hopefully temporary) workaround, we do a header-only fetch for the content-length header beforehand:
|
Adding good-beginner-bug label because I've already explained the issue and how it can be fixed in #9103 (comment) |
can anybody help me with the architecture of pdf.js . i'm working on the project. |
Attach (recommended) or Link to PDF file here:
https://jsfiddle.net/p3ybwp7d/1/
Configuration:
Steps to reproduce the problem:
Create loading task and add onProgress callback:
What is the expected behaviour? (add screenshot)
In previous versions,
onProgress
did return bothtotal
andloaded
.What went wrong? (add screenshot)
total
field is undefined inloadingTask.onProgress
callback.Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
https://jsfiddle.net/p3ybwp7d/1/
The text was updated successfully, but these errors were encountered: