-
Notifications
You must be signed in to change notification settings - Fork 62
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
add semi-portable looping using fsnotify #213
Conversation
generic defaultLoopRender for use in Backends
This looks really nice. I should have some time to test this on a Mac tomorrow. |
When i run your test program on my mac it generates the 5 pngs but then i get the message: Animation: select: Invalid argument and the program terminates. I'm running in a cabal sandbox, using cabal exec zsh. |
I added some special support for sandboxes, but I expect it just works with hsenv. I'll verify that on Linux. I don't know what that error is; I'll see if I can reproduce it, or at least figure out where it might come from, this evening. Thanks for testing! |
If i run it with -threaded i get: Animation: c_poll: invalid argument (Invalid argument) |
let frames = simulate (toRational $ animOpts^.fpu) anim | ||
nDigits = length . show . length $ frames | ||
forM_ (zip [1..] frames) $ \(i,d) -> mainRender (indexize out nDigits i opts) d | ||
defaultAnimMainRender :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a formatting change? (that's fine, I just want to make sure I'm not missing anything)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two let
lines are just reformatted, but there's a significant change before and after. Sorry about that.
Instead of getting mainRender
implicitly from the Mainable
instance, the first argument is a rendering function. This lets me write a defaultAnimMainRender
that doesn't know anything about looping, and a defaultLoopRender
that doesn't know anything about animations, at the expense of longer Mainable
instances. (See line 269 of diagrams/diagrams-cairo@ec32e9a) I like the modularity, but I could be convinced to use the approach in #195 instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. This is all a bit tricky. I think this approach works well, but I think we can do better (probably separate issue) with error messages. As it is right now if I give a file name that it can't use to pick the renderer I get an error message for each frame and it continues on to the looping. I think #195 has the same issue. My fault for not thinking through making errors modular as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I agree we can do better. Making a new issue for it sounds good.
@jeffreyrosenbluth That looks like https://ghc.haskell.org/trac/ghc/ticket/7325 . Is the right thing to pick a smaller delay value on MacOS? I have no confidence that the magic values for one machine will work on all machines, though. Can you edit Does the old-style looping work? That calls |
@bergey works for <=1e16 and fails for >=1e17. I didn't bother trying to pinpoint a more exact value since as you said, I don't realy have much confidence in magic values. I think I would go with something like 1e12. |
to work around https://ghc.haskell.org/trac/ghc/ticket/7325 fix lower bound on fsnotify—required for polling interval
Thanks! That's great. |
I think this is ready to merge. |
add semi-portable looping using fsnotify
generic defaultLoopRender for use in Backends
See matching branches of
-cairo
and-rasterific
.This seems to work well on Linux. It works some of the time on Windows; other times
fsnotify
seems to not register a change, or the program compiles and runs an older copy of the source file. Please don't merge until I have spent more time debugging that.I'd appreciate if someone could test this on a Mac. The
-rasterific
branch should be fine. My test program is:(there were some earlier bugs where it would recompile after the first edit, but not again)