greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
683 stars 92 forks source link

picts occasionally do not display in REPL #535

Closed ralsei closed 3 years ago

ralsei commented 3 years ago

Issue

Sometimes, when attempting to run code that displays a pict (or something akin) in the racket-mode REPL, the image does not show up, and instead just displays #<Image: path-to-image>. For example, with the same call:

requiring pict and running (standard-fish 100 50) twice, with one displaying text and the other displaying an image

M-x racket-bug-report

((alist-get 'racket-mode package-alist))
((emacs-version "28.0.50")
 (system-type gnu/linux)
 (x-gtk-use-system-tooltips nil)
 (major-mode racket-mode)
 (racket--el-source-dir "/home/hazel/.emacs.d/.local/straight/build-28.0.50/racket-mode/")
 (racket--rkt-source-dir "/home/hazel/.emacs.d/.local/straight/build-28.0.50/racket-mode/racket/")
 (racket-program "racket")
 (racket-command-timeout 10)
 (racket-xp-after-change-refresh-delay 1)
 (racket-xp-highlight-unused-regexp "^[^_]")
 (racket-repl-buffer-name-function nil)
 (racket-memory-limit 2048)
 (racket-error-context medium)
 (racket-history-filter-regexp "\\`\\s *\\'")
 (racket-images-inline t)
 (racket-images-keep-last 100)
 (racket-images-system-viewer "display")
 (racket-images-system-viewer "display")
 (racket-use-repl-submit-predicate nil)
 (racket-pretty-print t)
 (racket-indent-curly-as-sequence t)
 (racket-indent-sequence-depth 0)
 (racket-pretty-lambda nil)
 (racket-smart-open-bracket-enable nil)
 (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)")
 (racket-logger-config
  ((cm-accomplice . warning)
   (GC . info)
   (module-prefetch . warning)
   (optimizer . info)
   (racket/contract . error)
   (sequence-specialization . info)
   (* . fatal)))
 (racket-show-functions
  (racket-show-pseudo-tooltip)))
(enabled-minor-modes
 (+popup-mode)
 (TeX-PDF-mode)
 (TeX-source-correlate-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (better-jumper-local-mode)
 (better-jumper-mode)
 (column-number-mode)
 (company-mode)
 (display-line-numbers-mode)
 (doom-modeline-mode)
 (dtrt-indent-mode)
 (electric-indent-mode)
 (envrc-mode)
 (evil-escape-mode)
 (evil-goggles-mode)
 (evil-local-mode)
 (evil-mode)
 (evil-snipe-local-mode)
 (evil-snipe-mode)
 (evil-snipe-override-local-mode)
 (evil-snipe-override-mode)
 (evil-surround-mode)
 (evil-traces-mode)
 (file-name-shadow-mode)
 (flycheck-mode)
 (flycheck-popup-tip-mode)
 (font-lock-mode)
 (gcmh-mode)
 (general-override-mode)
 (git-gutter-mode)
 (global-company-mode)
 (global-eldoc-mode)
 (global-evil-surround-mode)
 (global-flycheck-mode)
 (global-font-lock-mode)
 (global-git-commit-mode)
 (global-hl-line-mode)
 (global-so-long-mode)
 (highlight-numbers-mode)
 (highlight-quoted-mode)
 (hl-line-mode)
 (hl-todo-mode)
 (hs-minor-mode)
 (ivy-mode)
 (ivy-prescient-mode)
 (ivy-rich-mode)
 (ivy-rich-project-root-cache-mode)
 (line-number-mode)
 (mouse-wheel-mode)
 (mpdel-mode)
 (parinfer-rust-mode)
 (persp-mode)
 (prescient-persist-mode)
 (projectile-mode)
 (racket-xp-mode)
 (rainbow-delimiters-mode)
 (ranger-override-dired-mode)
 (recentf-mode)
 (save-place-mode)
 (savehist-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (size-indication-mode)
 (smartparens-global-mode)
 (smartparens-mode)
 (solaire-global-mode)
 (solaire-mode)
 (transient-mark-mode)
 (vi-tilde-fringe-mode)
 (which-key-mode)
 (whitespace-mode)
 (window-divider-mode)
 (winner-mode)
 (ws-butler-global-mode)
 (ws-butler-mode)
 (yas-minor-mode))
(disabled-minor-modes
 (+emacs-lisp-ert-mode)
 (+javascript-gulp-mode)
 (+javascript-npm-mode)
 (+lsp-optimization-mode)
 (+org-pretty-mode)
 (+popup-buffer-mode)
 (LaTeX-math-mode)
 (TeX-Omega-mode)
 (TeX-interactive-mode)
 (abbrev-mode)
 (amx-debug-mode)
 (amx-mode)
 (auto-fill-function)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-visited-mode)
 (avy-linum-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (buffer-read-only)
 (button-mode)
 (cl-old-struct-compat-mode)
 (company-search-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (counsel-mode)
 (counsel-projectile-mode)
 (cursor-intangible-mode)
 (cursor-sensor-mode)
 (dash-fontify-mode)
 (defining-kbd-macro)
 (delete-selection-mode)
 (diff-auto-refine-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (dr-racket-like-unicode-mode)
 (dtrt-indent-global-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-quote-mode)
 (envrc-global-mode)
 (evil-collection-magit-toggle-text-minor-mode)
 (flymake-mode)
 (flyspell-mode)
 (general-override-local-mode)
 (git-commit-mode)
 (global-auto-revert-mode)
 (global-dash-fontify-mode)
 (global-display-line-numbers-mode)
 (global-git-gutter-mode)
 (global-hide-mode-line-mode)
 (global-hl-todo-mode)
 (global-prettify-symbols-mode)
 (global-reveal-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (global-vi-tilde-fringe-mode)
 (global-visual-line-mode)
 (global-whitespace-mode)
 (global-whitespace-newline-mode)
 (hide-mode-line-mode)
 (horizontal-scroll-bar-mode)
 (ibuffer-auto-mode)
 (ido-everywhere)
 (isearch-mode)
 (ispell-minor-mode)
 (jit-lock-debug-mode)
 (magit-auto-revert-mode)
 (magit-blame-mode)
 (magit-blame-read-only-mode)
 (magit-blob-mode)
 (magit-popup-help-mode)
 (magit-todos-mode)
 (magit-wip-after-apply-mode)
 (magit-wip-after-save-local-mode)
 (magit-wip-after-save-mode)
 (magit-wip-before-change-mode)
 (magit-wip-initial-backup-mode)
 (magit-wip-mode)
 (mail-abbrevs-mode)
 (mc-hide-unmatched-lines-mode)
 (menu-bar-mode)
 (mml-mode)
 (multiple-cursors-mode)
 (next-error-follow-minor-mode)
 (org-beamer-mode)
 (org-capture-mode)
 (org-cdlatex-mode)
 (org-list-checkbox-radio-mode)
 (org-src-mode)
 (org-table-follow-field-mode)
 (org-table-header-line-mode)
 (orgtbl-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (pcre-mode)
 (prettify-symbols-mode)
 (racket-smart-open-bracket-mode)
 (rectangle-mark-mode)
 (reveal-mode)
 (rxt--read-pcre-mode)
 (rxt-global-mode)
 (rxt-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (server-mode)
 (sh-electric-here-document-mode)
 (shell-command-with-editor-mode)
 (show-smartparens-global-mode)
 (show-smartparens-mode)
 (smartparens-global-strict-mode)
 (smartparens-strict-mode)
 (smerge-mode)
 (so-long-minor-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (table-fixed-width-mode)
 (table-mode-indicator)
 (tablist-edit-column-minor-mode)
 (tablist-minor-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (tooltip-mode)
 (transient-resume-mode)
 (unify-8859-on-decoding-mode)
 (unify-8859-on-encoding-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (which-function-mode)
 (whitespace-newline-mode)
 (with-editor-mode)
 (xref-etags-mode)
 (yas-global-mode))
greghendershott commented 3 years ago

Thanks for the report!

I tried to reproduce this with both Emacs 25.2 and 28.0.50. So far I can't get it to happen.

If you notice any particular pattern, that might help me narrow it down.

For instance is it always the first image after you (require pict)?

Once it works, does it work consistently thereafter?

OTOH if you really can't spot any pattern, and "sometimes" seems to be "random", that alone might be a good clue for me.

greghendershott commented 3 years ago

Well this is hilarious. I went off to do something else, came back to the REPL running from trying to repro this before.

I was going to exit it. But -- on a whim, not even consciously/intentionally -- I did M-p RET to repeat the (standard-fish 100 50).

And bingo, I got "#<Image: /var/tmp/racket-image-16208308591620830859694.svg>" instead of the image.

Furthermore, repeating this multiple times, I "randomly" got either an image or text.

So, although I haven't figured it out yet, I can definitely reproduce it, and answered my own questions from above.

ralsei commented 3 years ago

Yeah -- on my machine it's pretty much random as to whether an image or text appears, with no discernable pattern -- sometimes just re-running the file producing an image will work, sometimes it keeps displaying text and I have to restart Emacs...

greghendershott commented 3 years ago

Commit 2503951 seems to fix this for me. I say "seems" because the bug is maybe more intermittent, for me, than it was for you? So I can try N times but maybe it would fail N+1. Also I don't have a super-crisp "theory of the bug"; I just noticed one edge case and protected against that.

TL;DR the commit feels more ad hoc than I'd like.

Either way, thanks again for your help reporting!

ralsei commented 3 years ago

This appears to have worked. Running a plot as well as standard-fish cause me to be unable to reproduce the aforementioned behavior. Sometimes I briefly (split-second) see the #<Image: path> text, but it vanishes extremely quickly.

greghendershott commented 3 years ago

Thanks for confirming! Merged.