slipshow icon indicating copy to clipboard operation
slipshow copied to clipboard

hot-reload not working on mac

Open nilsbecker opened this issue 5 months ago • 11 comments

as the title says: when i run 'slipshow serve talk.md', changes in the markdown file are ignored. this happens at the level of the compilation already, i.e. 'slipshow compile --watch talk.md' also does not react to file changes.

this is on current macos 15.6

nilsbecker avatar Sep 08 '25 08:09 nilsbecker

I tried to work around this by running slipshow serve talk.md & in the background and calling slipshow compile talk.md manually. however, somehow the changed talk.html is also not refreshed and re-served by slipshow serve. browser page reload does not help. currently i have to rerun compile, serve and manually refresh the browser on every file update, which is not ideal to say the least.

nilsbecker avatar Sep 08 '25 08:09 nilsbecker

the notification API appears to be working. i was able to brew install fsevents-tools and then run notify-loop . ./script.sh where the script echoes a constant string. this worked when touching files present in the cwd.

i tried this workaround with the following script.sh:

slipshow compile talk.md
slipshow serve talk.md

which however did not work as expected. (it's also kind of double-watching the files)

nilsbecker avatar Sep 08 '25 08:09 nilsbecker

here an output of slipshow serve talk.md

slipshow serve -v talk.md
Visit http://127.0.0.1:8080 to view your presentation, with auto-reloading on file changes.
slipshow: [INFO] Watching /Users/me/the földer/
slipshow: [INFO] FSevents mode
slipshow: [INFO] updating file dependencies to  /Users/me/the földer/talk.md

no further update notifications appear when i edit and save talk.md. in case that matters, the folder name contains umlauts and spaces.

nilsbecker avatar Sep 08 '25 08:09 nilsbecker

OMG! it does matter. (and it's 2025...)

reloading works when i redo all of the above in the folder ~/Downloads

so there appears to be an issue with properly sanitizing filenames, afaics

nilsbecker avatar Sep 08 '25 08:09 nilsbecker

Hello and thanks for reporting and investigating this issue!

I could not reproduce on my Linux system ("Inotify mode"). I see several possibilities:

  • The bug is only present in MacOS ("FSEvents mode")
  • The bug is related to something else (like directory permission ?).

Unfortunately I don't have a Mac to test possibility 1. I hope to be able to borrow one to debug this issue!

panglesd avatar Sep 10 '25 07:09 panglesd

i can imagine that it's macos specific.

i don't think directory permissions are the problem. to pin this down i created three new directories test/, test la/ and test ö/ . all have the same permissions. in the first two, hot-reloading with slipshow serve works.

in the one with umlaut, it does not. interestingly, even a first compilation when invoking slipshow serve is not done that directory. slipshow compile does it, and then i can call slipshow serve, but further reloads are not done.

another directory, ö/ also does not work. so presence of an umlaut appears to be enough to break it.

finally, i also tried renaming the .md file to one with umlaut, so i now have test/tölk.md. interestingly, this does successfully hot-reload.

so it's specifically directory names with umlauts that appear to be the problem.

nilsbecker avatar Sep 10 '25 09:09 nilsbecker

i also now installed fsevents-tools which contains a simple test cli app, notifyloop which uses FSEvents to watch a directory and run a script. if i watch ö/ and externally change ö/talk.md, then the script is run. so the upstream FSEvents can successfully watch that directory. it would be weird otherwise since this is a heavily used piece of functionality....

nilsbecker avatar Sep 10 '25 09:09 nilsbecker

Thanks a lot for confirming the source of the issue.

Slipshow use irmin-watcher, a "multiplatform" watching tool, using inotify on Linux, FSEvent on Mac and "time-interval based" watching elsewhere. Since the issue is MacOS-only, and FSEvent itself is (unsuprisingly) not at fault, the only remaining "macos-only" piece of code is in irmin-watcher... (or my repro on Linux failed for unknown reason.)

I'll investigate! But if you have time, I'd appreciate if you could paste the output of slipshow serve ö/talk.md, --verbosity=debug!

panglesd avatar Sep 10 '25 12:09 panglesd

ok!

slipshow serve ö/talk.md --verbosity=debug
Visit http://127.0.0.1:8080 to view your presentation, with auto-reloading on file changes.
slipshow: [INFO] Watching /Users/.../ö/
slipshow: [INFO] FSevents mode
slipshow: [DEBUG] start_runloop /Users/.../ö
slipshow: [DEBUG] Start watchdog for /Users/.../ö
slipshow: [INFO] updating file dependencies to /Users/.../ö/talk.md

This is the initial output. after changing and saving ö/talk.md, nothing else appears.

nilsbecker avatar Sep 10 '25 14:09 nilsbecker

for comparison:

slipshow serve a/talk.md --verbosity=debug
Visit http://127.0.0.1:8080 to view your presentation, with auto-reloading on file changes.
slipshow: [INFO] Watching /Users/.../a/
slipshow: [INFO] FSevents mode
slipshow: [DEBUG] start_runloop /Users/.../a
slipshow: [DEBUG] Start watchdog for /Users/.../a
slipshow: [INFO] updating file dependencies to /Users/.../a/talk.md
slipshow: [DEBUG] fsevents: /Users/.../a/talk.html
slipshow: [DEBUG] files=[] new_files=[(talk.html,
                                       1f99b1d4d6bc7d4d2b3980ea8a6e014a)]
slipshow: [DEBUG] [0] polling /Users/.../a: diff:[(talk.html,
                                                       1f99b1d4d6bc7d4d2b3980ea8a6e014a)]
slipshow: [DEBUG] callback 0

appears to do more!

nilsbecker avatar Sep 10 '25 15:09 nilsbecker

I could reproduce on a Mac VM! I'll get on it as soon as I have time (maybe only after FunOCaml)

panglesd avatar Sep 10 '25 21:09 panglesd