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

Activating pdf-view-auto-slice-minor-mode leads to blank grey pages #12

Open
haselwarter opened this issue Sep 14, 2022 · 17 comments
Open

Comments

@haselwarter
Copy link

haselwarter commented Sep 14, 2022

Firstly, thank you for writing image-roll and toc-mode.

It would be great to merge your pdf-roll for of pdf-tools, and to publish image-roll. pdf-tools is pretty popular, and the scrolling that image-roll brings is a massive improvement. Ideally, upstreaming your changes could reduce your maintenance burden on the fork and on image-roll. I understand that this would require some polishing. I use pdf-tools a lot, and getting image-roll properly integrated would be useful to me. How much of a donation would help you fix this issue, and move forward with publishing image-roll?

Now, for the actual bug report.

pdf-view-roll-minor-mode seems to have issues with pdf-view-auto-slice-minor-mode. Notably, it leads to pages not being displayed. Instead, a grey page is shown, and it's impossible to scroll past this grey page. M-x redraw-display mostly seems to bring back the view of the pdf.

Tested with GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-09-12, on wayland (sway).

Here's the recipe I used with a clean Emacs config.

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package
 '(pdf-tools :type git
             :host github
             :fork (:repo "dalanicolai/pdf-tools" :branch "pdf-roll")
             :files ("lisp/*.el"
                     "README"
                     ("build" "Makefile")
                     ("build" "server")
                     (:exclude "lisp/tablist.el" "lisp/tablist-filter.el"))))

(straight-use-package
 '(image-roll
   :host github
   :repo "dalanicolai/image-roll.el"))
(require 'pdf-tools)
(pdf-tools-install)
(require 'image-roll)

Edit: It seems these issues with redisplay already happen without auto-slice-mode. They happen less frequently, but often enough to be a bother.

@dalanicolai
Copy link
Owner

Thanks for enjoying image-roll and toc-mode. I will probably not work any more on image-roll, as I am/have been working on its successor. I did not write much about it yet, but you can have a look at minad/consult#625 to get an impression. If you like, you can already test a 'pdf-tools' version of the thumbs side window, by simply loading the code here, however this requires the mutool (from mupdf) command to be available.

About donations, well, any kind of donation would help me a lot. Developing these packages takes a lot of work, and a massive amount of investigation (especially the things that are not documented, like the redisplay functionality. I will try to soon publish some article about the need for documentation).

@averter
Copy link

averter commented Sep 16, 2022

I am experiencing exactly the same issue described by @haselwarter after upgrading to emacs 28 and installing pdf-tools + image-roll. Given that redraw-display restores the image we could implement a dirty hack and run this command within a hook whenever the pages become blank grey? Any other ideas/suggestions?

@averter
Copy link

averter commented Sep 16, 2022

toggle-debug-on-error indicates an issue in this function image-roll-undisplay-page

Debugger entered--Lisp error: (error "Invalid image specification")
  image-size(((slice 103 189 647 869) (image :type png :data "\211PNG\15\n\32\n\0\0\0\15IHDR\0\0\3}\0\0\4\204\10\2\0\0\0_\322\361\261\0\0 \0IDATx\1\354\235\5\270\35\305\371..." :scale 1 :margin (0 . 2) :width 893 :map (((rect (337 . 268) 348 . 288) link-8-1 (pointer hand help-echo "Goto page 7")) ((rect (493 . 289) 505 . 309) link-8-2 (pointer hand help-echo "Goto page 7")) ((rect (287 . 835) 298 . 856) link-8-3 (pointer hand help-echo "Goto page 8")) ((rect (161 . 187) 730 . 207) pdf-view-text-region (pointer text)) ((rect (131 . 207) 352 . 228) pdf-view-text-region (pointer text)) ((rect (161 . 244) 559 . 264) pdf-view-text-region (pointer text)) ((rect (187 . 267) 730 . 270) pdf-view-text-region (pointer text)) ((rect (131 . 270) 147 . 288) pdf-view-text-region (pointer text)) ((rect (187 . 270) 730 . 288) pdf-view-text-region (pointer text)) ((rect (187 . 288) 730 . 289) pdf-view-text-region (pointer text)) ((rect (161 . 289) 730 . 309) pdf-view-text-region (pointer text)) ((rect (131 . 309) 616 . 330) pdf-view-text-region (pointer text)) ((rect (279 . 340) 611 . 344) pdf-view-text-region (pointer text)) ((rect (279 . 344) 611 . 365) pdf-view-text-region (pointer text)) ((rect (706 . 344) 730 . 365) pdf-view-text-region (pointer text)) ((rect (279 . 365) 611 . 369) pdf-view-text-region (pointer text)) ((rect (161 . 378) 730 . 401) pdf-view-text-region (pointer text)) ((rect (124 . 401) 147 . 419) pdf-view-text-region (pointer text)) ((rect (161 . 401) 730 . 419) pdf-view-text-region (pointer text)) ((rect (161 . 419) 730 . 420) pdf-view-text-region (pointer text)) ((rect (161 . 420) 331 . 441) pdf-view-text-region (pointer text)) ((rect (407 . 444) 438 . 447) pdf-view-text-region (pointer text)) ((rect (390 . 447) 398 . 458) pdf-view-text-region (pointer text)) ((rect (407 . 447) 438 . 458) pdf-view-text-region (pointer text)) ((rect (320 . 458) 378 . 463) pdf-view-text-region (pointer text)) ((rect (390 . 458) 398 . 463) pdf-view-text-region (pointer text)) ((rect (407 . 458) 438 . 463) pdf-view-text-region (pointer text)) ((rect (442 . 458) 572 . 463) pdf-view-text-region (pointer text)) ((rect (706 . 458) 730 . 463) pdf-view-text-region (pointer text)) ((rect (320 . 463) 378 . 469) pdf-view-text-region (pointer text)) ((rect (390 . 463) 398 . 469) pdf-view-text-region (pointer text)) ((rect (442 . 463) 572 . 469) pdf-view-text-region (pointer text)) ((rect (706 . 463) 730 . 469) pdf-view-text-region (pointer text)) ((rect (320 . 469) 378 . 470) pdf-view-text-region (pointer text)) ((rect (442 . 469) 572 . 470) pdf-view-text-region (pointer text)) ((rect (706 . 469) 730 . 470) pdf-view-text-region (pointer text)) ((rect (320 . 470) 378 . 480) pdf-view-text-region (pointer text)) ((rect (384 . 470) 441 . 480) pdf-view-text-region (pointer text)) ((rect (442 . 470) 572 . 480) pdf-view-text-region (pointer text)) ((rect (706 . 470) 730 . 480) pdf-view-text-region (pointer text)) ((rect (384 . 480) 441 . 495) pdf-view-text-region (pointer text)) ((rect (161 . 504) 730 . 509) pdf-view-text-region (pointer text)) ((rect (124 . 509) 147 . 527) pdf-view-text-region (pointer text)) ((rect (161 . 509) 730 . 527) pdf-view-text-region (pointer text)) ((rect (161 . 527) 730 . 528) pdf-view-text-region (pointer text)) ((rect (161 . 528) 667 . 549) pdf-view-text-region (pointer text)) ((rect (372 . 562) 519 . 582) pdf-view-text-region (pointer text)) ((rect (706 . 562) 730 . 582) pdf-view-text-region (pointer text)) ((rect (161 . 596) 730 . 598) pdf-view-text-region (pointer text)) ((rect (124 . 598) 147 . 616) pdf-view-text-region (pointer text)) ...) :pointer arrow :relief 0 :transform-smoothing t)) t)
  image-roll-undisplay-page(8)
  image-roll-update-displayed-pages()
  image-roll-scroll-forward(t)
  image-roll-scroll-backward()
  (let ((_ --dotimes-counter--)) (image-roll-scroll-backward))
  (while (< --dotimes-counter-- --dotimes-limit--) (let ((_ --dotimes-counter--)) (image-roll-scroll-backward)) (setq --dotimes-counter-- (1+ --dotimes-counter--)))
  (let ((--dotimes-limit-- (or arg 1)) (--dotimes-counter-- 0)) (while (< --dotimes-counter-- --dotimes-limit--) (let ((_ --dotimes-counter--)) (image-roll-scroll-backward)) (setq --dotimes-counter-- (1+ --dotimes-counter--))))
  (if pdf-view-roll-minor-mode (let ((--dotimes-limit-- (or arg 1)) (--dotimes-counter-- 0)) (while (< --dotimes-counter-- --dotimes-limit--) (let ((_ --dotimes-counter--)) (image-roll-scroll-backward)) (setq --dotimes-counter-- (1+ --dotimes-counter--)))) (pdf-view--previous-line-or-previous-page arg))
  pdf-view-previous-line-or-previous-page(1)
  funcall-interactively(pdf-view-previous-line-or-previous-page 1)
  call-interactively(pdf-view-previous-line-or-previous-page nil nil)
  command-execute(pdf-view-previous-line-or-previous-page)

@dalanicolai
Copy link
Owner

dalanicolai commented Sep 16, 2022

I have pushed a 'partial fix'. PR's for better fixes are welcome, but as mentioned in my previous comment, I will not spend more time on this package because of other priorities.

@dalanicolai
Copy link
Owner

I accidentally deleted the wrong line in that fix... but I have put that line back now... so it should work now

@averter
Copy link

averter commented Sep 22, 2022

Thanks but unfortunately it does not. I can't even activate the package and am receiving this error

File mode specification error: (error Autoloading file /home/myusername/.emacs.d/elpa/image-roll-20220917.2148/image-roll.elc failed to define function pdf-view-roll-minor-mode)

and when running C-c f on the function name

pdf-view-roll-minor-mode is an autoloaded interactive Lisp function in
‘image-roll.el’.

[Arg list not available until function definition is loaded.]

Not documented.

I totally understand that you have other priorities besides this package, but I would like to know if the old pdf-continuous-scroll package also works on 28.1, given that pcs has no conflicts with pdf-view-auto-slice-minor-mode, nor creates strange grey pages. I can live with the fact that it is not a true continuous scrolling system :-). Thank you in advance.

@dalanicolai
Copy link
Owner

Are you using the pdf-roll branch of my pdf-tools fork? Because I remember that is required for using image-roll. From the error, it looks like the pdf-roll file is not loaded correctly before you are trying to use image-roll, so maybe you should reinstall that pdf-roll branch first.

If that does not work, indeed the old continuous-scroll package should work fine on Emacs 28/29 as far as I know.

@averter
Copy link

averter commented Sep 27, 2022

@dalanicolai thanks for your reply/confirmation, but it is still not working, despite using your pdf-tools package. @haselwarter Sorry for introducing extra stuff into your issue.
For reference this is how I am calling both packages, using quelpa-use-package

(use-package pdf-tools
  :after (quelpa)
  :ensure t
  :magic ("%PDF" . pdf-view-mode)
  ;; default page width behaviour 
  :hook ((pdf-view-mode . pdf-view-auto-slice-minor-mode))
  ;; use Ctrl+home/end keys to move to the first/last page
  :bind (:map pdf-view-mode-map
              ("<home>" . 'pdf-view-first-page)
              ("<end>" . 'pdf-view-last-page))
  :quelpa (pdf-tools :fetcher github
                     :repo "dalanicolai/pdf-tools"
                     :branch "pdf-roll"
                     :files ("lisp/*.el"
                             "README"
                             ("build" "Makefile")
                             ("build" "server")
                             (:exclude "lisp/tablist.el" "lisp/tablist-filter.el")))
  )

(use-package image-roll
  :ensure t
  :after (pdf-tools)
  :hook ((pdf-view-mode . pdf-view-roll-minor-mode)
         )
  :quelpa (image-roll :fetcher github
                      :repo "dalanicolai/image-roll.el"
                      :upgrade t)
  )

@dalanicolai
Copy link
Owner

I am not sure how I used to load pdf-roll.el, but it looks that file is not loaded. Try to call M-x find-libary pdf-tools and pdf-roll manually, before trying to open some pdf. If that fixes the problem, then you should probably additionally somehow require pdf-roll when loading/requiring pdf-tools.

@averter
Copy link

averter commented Sep 27, 2022

I am not sure how I used to load pdf-roll.el, but it looks that file is not loaded. Try to call M-x find-libary pdf-tools and pdf-roll manually, before trying to open some pdf. If that fixes the problem, then you should probably additionally somehow require pdf-roll when loading/requiring pdf-tools.

Did you mean image-roll instead of pdf-roll? I am able to find both pdf-tools and image-roll (the .el files show up) but that does not fix the problem, i.e., the function is still not recognized when opening a pdf. I have also tried to introduce

  :config
    (require 'image-roll)

in the above setup to no avail :-(

@haselwarter
Copy link
Author

haselwarter commented Sep 27, 2022 via email

@dalanicolai
Copy link
Owner

@averter I mean pdf-roll. So even though you installed the pdf-roll branch of pdf-tools, you do not find it using M-x find-library?

@averter
Copy link

averter commented Sep 27, 2022

Thanks both for all the help. I have tried several things and it does not work no matter what I try :-( , so I think I will give up on this one/it is just too much hassle to handle, and I will revert back to the old pdf-continuous-scroll package. Thanks again.

@dalanicolai
Copy link
Owner

@haselwarter If you'd like to open the files with pdf-view-roll-minor-mode active then you could try

(add-hook 'pdf-view-mode-hook (lambda () (run-with-timer 0.1 nil #'pdf-view-roll-minor-mode)))

@averter It means loading pdf-roll first did not work? Or were you not able to find it?

@averter
Copy link

averter commented Sep 29, 2022

@dalanicolai even though I had installed your version of pdf-tools I was not able to find pdf-roll.

@dalanicolai
Copy link
Owner

Okay, when I simply install my branch here (using quelpa) then I can find pdf-roll using M-x find-library. However, if that does not work, then you should be able to find it in the in pdf-tools.../lisp directory within your elpa directory.
To get there, you could simply do M-x find-library pdf-view, as that package is located in the same directory. From there you can search for the pdf-roll package. If it is not in that directory, then you are not using the pdf-roll branch somehow.

@haselwarter
Copy link
Author

haselwarter commented Sep 29, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants