ankit / stylebot

Change the appearance of the web instantly
https://stylebot.dev/
MIT License
1.39k stars 206 forks source link

[Bug] Default Chrome PDF viewer does not display PDF when Stylebot extension is on. #650

Open Eternyte opened 3 years ago

Eternyte commented 3 years ago

Describe the bug

When Stylebot extension is enabled in Google Chrome, certain PDFs have a high probability of not displaying.

This is likely due to Stylebot, because of the following factors:

  1. There are no PDF display issues when browsing in incognito.
  2. There are no PDF display issues when all other extensions are on besides for Stylebot.
  3. There are no PDF display issues when Stylebot site access is limited to specific pages.
    • Go to chrome://extensions/ > Stylebot > Details > Site access > On specific sites > Set to specific sites.
  4. There are PDF display issues when Stylebot extension is on and site access is set to "On all sites".

Certain user actions in this state will cause the PDF to display on the page again:

  1. Zooming in or out on the page will cause the PDF to display.
  2. Rotating the PDF will cause the PDF to display.
  3. Fitting the PDF to "fit to page" will cause the PDF to display.
    • "Fit to page" is the default setting. Clicking on the icon once will set it to "fit to width".
    • "Fit to width" will not cause the PDF to display. Clicking on the icon once more will set it to "fit to page".
    • At this point, the PDF will display, so you'll need to click on the icon twice overall.

The following user actions in this state will not result in getting the PDF to be displayed:

  1. Displaying the Stylebot side panel ("Open Stylebot") will not cause the PDF to be displayed.
  2. Changing the PDF page number ("1/1" on the top) will not cause the PDF to be displayed.
    • Since the PDF is not displayed, the page number at the top is always "1/1".
  3. Scrolling on this page will not cause the PDF to show.

On refreshing the page:

Refreshing the page will occasionally get the PDF to be displayed without requiring any user actions. Sometimes, when refreshing repeatedly, the PDF will display correctly multiple times in a row. However, other times, when refreshing repeatedly, the PDF will fail to be displayed properly, roughly at worst, nine in ten times. This is true when refreshing with the refresh button in the browser, refreshing with F5, and hard refreshing with Ctrl + Shift + R.

Browser

Browser: Google Chrome Version 90.0.4430.212 (Official Build) (64-bit) Operating System: Windows 10 Home 19042.985

To Reproduce

  1. Go to chrome://extensions/.
  2. Toggle Stylebot on if not already on.
  3. Go to http://www.africau.edu/images/default/sample.pdf.
  4. Note that most of the time, the PDF is not displayed without user action.
  5. Go to chrome://extensions/.
  6. Toggle Stylebot off.
  7. Go to http://www.africau.edu/images/default/sample.pdf, or refresh the tab in step 3.
  8. Note that the PDF is always displayed, with or without user action.

Expected behavior

PDF is displayed correctly every time without requiring user action.

Screenshots

This is what it looks like when the PDF is not displayed correctly: no display

Additional context

Here are other details regarding this bug:

  1. There are no Stylebot CSS configurations for any of the PDF pages.
  2. There are no console log errors that are displayed in Developer Tools.
  3. There are no network errors. It is a successful GET call with HTTP response code 304.
    • No extra calls are made to request the PDF again, even after user action.

Here are some more PDF files that also display this issue:

  1. http://s.wsj.net/blogs/html/wsjcrypticguide.pdf
  2. https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
  3. https://neo4j.com/docs/pdf/neo4j-getting-started-4.2.pdf
  4. http://www.firstfriendk9.com/uploads/2/8/2/6/2826757/25_human_foods_toxic_to_dogs.pdf
  5. https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf

Most PDFs I've encountered have this issue though, so pretty much any PDF will work.

However, I've found that some PDF files display correctly every time without user action:

  1. https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
  2. https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf

Timeline

I first actively noticed this issue May 1, 2021 when I had to look at several PDF documents. This issue may have occurred prior to that date, but it's unlikely that this issue has been occurring for months, because I probably would have noticed this issue sooner. Therefore, this bug was likely introduced around April based on commit history for this project and timeline.