Skip to content
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

Unhandled Promise rejection: TextHighlighter is already enabled. #1501

Closed
skyleguy opened this issue Aug 19, 2022 · 10 comments
Closed

Unhandled Promise rejection: TextHighlighter is already enabled. #1501

skyleguy opened this issue Aug 19, 2022 · 10 comments
Assignees
Labels
Can't reproduce the bug You've reported a bug, but the feature works fine on my machine. So I don't know how to help you. help wanted Extra attention is needed nuisance a bug that only shows in the logs; or: a bug with an obvious work-around every user finds quickly Solved

Comments

@skyleguy
Copy link

skyleguy commented Aug 19, 2022

No

No

Unfortunately the PDFs we are using contain confidential info so I cannot supply the PDF I am using but can supply the options im passing to the extended pdf viewer

Describe the bug
When opening the viewer with documents from my company I am seeing this error happen frequently (but not always)

Version info

  • Version of ngx-extended-pdf-viewer: 15.0.0-alpha.4 and 13.5.2

Desktop (please complete the following information):

  • Chrome

To Reproduce

  1. use version 15.0.0-alpha.4 (also present in 13.5.2)
  2. setup pdf viewer like so:
    <ngx-extended-pdf-viewer
      [src]="pdfSrc"
      [showToolbar]="false"
      [handTool]="false"
      [textLayer]="true"
      [showBorders]="false"
      zoom="page-width"
      backgroundColor="rgb(242 242 242)"
      [page]="1"
    ></ngx-extended-pdf-viewer>
  1. PDF displays fine but error displays in console when pdf is rendered

Screenshots

Screen Shot 2022-08-19 at 1 10 44 PM

@stephanrauh stephanrauh self-assigned this Aug 19, 2022
@stephanrauh
Copy link
Owner

This bug (or nuisance - as far as I can see, it's just a warning) doesn't show on my machine, so I need your help. Please add the attribute [minifiedJSLibraries]="false" so you can debug. Add a breakpoint in the viewer*.js at this line:
https://github.com/stephanrauh/pdf.js/blob/b834a0ca61f28800f3c7b83b0bc522dc4230383d/web/text_highlighter.js#L65

I suppose it's interesting to observe the calling function. The text highlighter is enabled twice, but I don't understand how that's possible. I suspect there's a text highlighter for each page, and maybe it's activated both for the text layer and for XFA forms. Does you PDF file use such a form?

@stephanrauh stephanrauh added help wanted Extra attention is needed nuisance a bug that only shows in the logs; or: a bug with an obvious work-around every user finds quickly waiting for the user's answer Can't reproduce the bug You've reported a bug, but the feature works fine on my machine. So I don't know how to help you. labels Aug 19, 2022
@skyleguy
Copy link
Author

the particular pdf im using only has one page actually.

After setting the breakpoint there i do see it get hit twice. The first time the value of textDivs and textContentItemsStr are both empty arrays and the enabled field is false. The second time the textDivs and textContentItemsStr are both filled with 119 element/strings and then the error gets thrown because enabled is already true

@stephanrauh
Copy link
Owner

I have to admit I'm not familiar with that part of the implementation of pdf.js. I'm just the guy providing an Angular wrapper for it. So I can't decide whether the empty arrays are OK or not. My gut says it sounds fishy, but that's just a guess.

What about the stack trace - can you spot a difference there?

Plus, I wonder if the bug has something to do with your PDF document. Here's a small selection of demo PDFs: https://github.com/stephanrauh/extended-pdf-viewer-showcase/tree/main/src/assets/pdfs. Does the bug happen with these PDF files, too?

@skyleguy
Copy link
Author

interestingly enough it does not seem to happen on a few of the pdfs with text that ive tried from that folder... really not sure whats going on there. Even more strange it does not happen to my document every time either. im not seeing anything else to indicate the issue in the stacktrace unfortunately

@skyleguy
Copy link
Author

skyleguy commented Aug 23, 2022

im extremely unfamiliar with the expected format of PDFs, do you have any ideas as to what I could look for in our internal PDFs that may be causing this issue to happen?

Also you mentioned this is a nuisance more than a bug as it is a warning, would it be possible to replace the Error throwing with a console warn instead?

@stephanrauh
Copy link
Owner

I'm almost as unfamiliar with the format of PDF files as you are! :)

In any case, you can remove the error message yourself: https://pdfviewer.net/extended-pdf-viewer/filtering-console-log

stephanrauh added a commit to stephanrauh/pdf.js that referenced this issue Aug 27, 2022
…if the text highlighter is initialized twice
stephanrauh added a commit to stephanrauh/pdf.js that referenced this issue Aug 27, 2022
…if the text highlighter is initialized twice
@stephanrauh
Copy link
Owner

I've removed the error message. Now the code doesn't throw an exception. I don't think that's going to cause problems, but I'd appreciate your test (once I've published version 15.0.0-alpha.6).

@skyleguy
Copy link
Author

sure ill check it out once that version drops. interestingly enough im unable to see that error being logged from the log filter (which im currently using to filter out those warn messages i mentioned in another issue I brought up)

@stephanrauh
Copy link
Owner

The error message is thrown as an exception, so maybe it slips the attention of my filter implementation.

Yesterday, Tim caught me by surprise when he released a new version of pdf.js, so I guess the final release of version 15 is delayed another few days.

@stephanrauh
Copy link
Owner

I've just published version 15.0.0-alpha.6. Two-way binding of forms is broken (#1516), but I guess that's not your use-case, so please run a test.

stephanrauh added a commit that referenced this issue Aug 30, 2022
…zed twice; updated to pdf.js 2.16 (default branch) and pdf.js 3.0 (bleeding edge branch); #1516 fix broken two-way binding of forms (work in progress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can't reproduce the bug You've reported a bug, but the feature works fine on my machine. So I don't know how to help you. help wanted Extra attention is needed nuisance a bug that only shows in the logs; or: a bug with an obvious work-around every user finds quickly Solved
Projects
None yet
Development

No branches or pull requests

2 participants