eikek / docspell

Assist in organizing your piles of documents, resulting from scanners, e-mails and other sources with miminal effort.
https://docspell.org
GNU Affero General Public License v3.0
1.65k stars 127 forks source link

PDF viewer still shows previous document when opening another document in macOS Safari #2446

Closed lehnerpat closed 10 months ago

lehnerpat commented 10 months ago

Intro & problem summary

Hello again!

I'm observing another issue: once I open a document in Docspell in Safari on macOS, the PDF viewer is "stuck" on that document even when switching to another document. Reloading the page makes it load the other document, but it means I have to reload every time I open another document.

This seems to be the same / similar to https://github.com/eikek/docspell/issues/1210.

Reproducing the problem on v0.40.0

Note: This is the same setup as in the other issue I just opened, https://github.com/eikek/docspell/issues/2445.

  1. Set up Docspell with docker compose, following the docker compose section of the installation manual. Since I wanted to use a release version, I deviated from the manual by downloading the docker compose file from tag v0.40.0 instead. Specifically, I did these steps:

    > cd /tmp
    > pwd
    /tmp
    > mkdir -p docspell/docker/docker-compose
    > cd docspell/docker/docker-compose
    > pwd
    /tmp/docspell/docker/docker-compose
    > wget https://raw.githubusercontent.com/eikek/docspell/v0.40.0/docker/docker-compose/docker-compose.yml
    --2023-12-30 16:45:25--  https://raw.githubusercontent.com/eikek/docspell/v0.40.0/docker/docker-compose/docker-compose.yml
    Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8003::154, 2606:50c0:8000::154, 2606:50c0:8001::154, ...
    Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8003::154|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 4740 (4.6K) [text/plain]
    Saving to: ‘docker-compose.yml’
    
    docker-compose.yml  100%[===================>]   4.63K  --.-KB/s    in 0s
    
    2023-12-30 16:45:25 (20.2 MB/s) - ‘docker-compose.yml’ saved [4740/4740]
    
    > ls -A
    docker-compose.yml
    > docker-compose up -d
    [+] Building 0.0s (0/0)                                    docker:desktop-linux
    [+] Running 8/8
    ✔ Network docker-compose_default                  Created                 0.0s
    ✔ Volume "docker-compose_docspell-postgres_data"  Created                 0.0s
    ✔ Volume "docker-compose_docspell-solr_data"      Created                 0.0s
    ✔ Container docspell-solr                         Started                 0.0s
    ✔ Container postgres_db                           Started                 0.1s
    ✔ Container docspell-joex                         Started                 0.1s
    ✔ Container docspell-restserver                   Started                 0.1s
    ✔ Container docspell-consumedir                   Started                 0.0s
    • FYI, here are the containers that were created, and the images that they use:

      > docker ps
      CONTAINER ID   IMAGE                        COMMAND                  CREATED         STATUS                   PORTS                    NAMES
      1045dbbbd81a   docspell/dsc:latest          "dsc -d http://docsp…"   5 minutes ago   Up 5 minutes                                      docspell-consumedir
      9afa894f6acb   docspell/joex:latest         "/opt/joex-entrypoin…"   5 minutes ago   Up 5 minutes (healthy)   0.0.0.0:7878->7878/tcp   docspell-joex
      90faedb8cdca   docspell/restserver:latest   "/opt/docspell-rests…"   5 minutes ago   Up 5 minutes (healthy)   0.0.0.0:7880->7880/tcp   docspell-restserver
      d0ea7652c5a4   solr:9                       "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes (healthy)   8983/tcp                 docspell-solr
      adf3c972c07f   postgres:15.2                "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes             5432/tcp                 postgres_db
      
      > docker image ls
      REPOSITORY           TAG     IMAGE ID       CREATED        SIZE
      solr                 9       3c38c30d646b   13 days ago    593MB
      postgres             15.2    bf700010ce28   8 months ago   379MB
      docspell/dsc         latest  54d581f6c5a1   9 months ago   20.1MB
      docspell/joex        latest  d129a81f07fd   9 months ago   1.99GB
      docspell/restserver  latest  1e700758d41a   9 months ago   336MB
  2. Open the web UI at http://localhost:7880 and create a new collective + user using the "Sign up!" button.

    • Collective ID: issuerepro User Login: issuerepro Password: issuerepro
  3. Prepare any two documents (I'm using the two example documents from https://github.com/eikek/docspell/issues/2445 here).

  4. Upload the documents to Docspell via the web UI:

    • Open the dashboard (http://localhost:7880/app/dashboard), and log in with user issuerepro that we created above.
    • Choose the files via drag-and-drop or using the "Select..." button in the drop area on the dashboard.
    • Click "Submit".
    • Wait for processing to finish (should be relatively quick, since no OCR needs to be done).
  5. Open one document (the PDF is shown in the viewer on the right), then open the other document (it doesn't matter if you use the "next/previous" button in the detail view or return to the folder / dashboard).

    • In Safari 17.1.2 (19616.2.9.11.12), the old document is still shown: screen recording

    • In Chrome 120.0.6099.129 (Official Build) (x86_64), it properly loads the second document: screen recording

    • In Firefox 121.0 (64-bit), it also properly loads the second document: screen recording

Some more version / environment information

lehnerpat commented 10 months ago

Quick update:

I also just re-tried this with the current nightly version (i.e., using :nightly instead of :latest for all three docspell images in the docker compose file), specifically:

docspell/joex        nightly  b5506a7ff399   26 hours ago   2.09GB
docspell/restserver  nightly  1dbcd0bd96c6   26 hours ago   333MB
docspell/dsc         nightly  880e97d301f3   3 months ago   22.8MB

And this issue still exists the same way in Safari 😭

eikek commented 10 months ago

Hi @lehnerpat, it seems to me this issue is a duplicate of #1210 ? There are issues with the embed element and safari. Please use firefox instead or swtich to the "cross browser view" (see also here).

lehnerpat commented 10 months ago

Hi @eikek, thanks for your quick response here as well!

Ah yes, after looking again, this is indeed a duplicate of #1210. Sorry for not noticing this before. With the "cross-browser viewer mode" enabled, it works fine in Safari.

I think I had previously seen that comment, but I couldn't figure out what "cross browser view" meant or how to enable it, and I couldn't find anything about it in the documentation 🤔 It would be great if you could add this at some point 🙇 Or if there's already a good place in the documentation where this could go, I'm happy to open a PR for it if you point me in the right direction ☺️

Additionally, I wonder if the <embed> could be made to work correctly (or at least better?) in Safari by removing it from the DOM before changing its src, and then re-inserting it with the new src (as suggested by this SO answer). I'm sure you've previously researched this issue before introducing the cross-browser viewer mode, so not sure if you've tried this before.

I don't have a Scala / Elm dev env set up, so I can't easily test this properly. But I did shortly try it in the browser console, and it seemed to behave in the desired way. Not sure how easy it is to make Elm remove + remount the element instead of just changing it in place though 😅

Anyway, for now this issue can be closed as a duplicate of #1210 👍

eikek commented 10 months ago

Ah yes, after looking again, this is indeed a duplicate of #1210. Sorry for not noticing this before. With the "cross-browser viewer mode" enabled, it works fine in Safari.

Ah nice and no worries!

I think I had previously seen that comment, but I couldn't figure out what "cross browser view" meant or how to enable it, and I couldn't find anything about it in the documentation 🤔 It would be great if you could add this at some point 🙇

Yes you are right. This should be somewhere in the docs. Perhaps a new item under Web UI is necessary that introduces the user settings. If you find some time to add this, that would be great of course. You can base it against the current-docs branch.

Additionally, I wonder if the <embed> could be made to work correctly (or at least better?) in Safari by removing it from the DOM before changing its src, and then re-inserting it with the new src (as suggested by this SO answer). I'm sure you've previously researched this issue before introducing the cross-browser viewer mode, so not sure if you've tried this before.

It's been some time, I can't remember much of what I tried back then. With elm you can't really decide when something is mounted/unmounted. Probably there is a way to "trick" it do to it in this way (maybe by artificially changing a parent element) - I don't know. If someone finds a way that is not a bad hack 😄 then I'd happy to merge it. But I myself don't have much interest investing time in circumventing this safari issue tbh 😄.

lehnerpat commented 10 months ago

But I myself don't have much interest investing time in circumventing this safari issue tbh 😄.

Yes, that's fair, browser compatibility is a pain 😅

Yes you are right. This should be somewhere in the docs. Perhaps a new item under Web UI is necessary that introduces the user settings. If you find some time to add this, that would be great of course. You can base it against the current-docs branch.

Sorry to back out after offering to contribute first, but I ended up not going with Docspell for now (paperless-ngx fits my usecase better and seems more mature), so I don't have Docspell running anymore. I hope this issue is another breadcrumb for people in a similar situation, until the docs are expanded :)

Thanks again!