minttea icon indicating copy to clipboard operation
minttea copied to clipboard

Configurable framerate and diff-rendering

Open leostera opened this issue 1 year ago • 2 comments

          @leostera This is awesome sauce! I think the situation has improved for me but not entirely.

I still see an issue from #34 but it happens not so frequently to me. Previously, I had to restart my app 7 times to avoid hanging. Now I need to restart it 7 times to observe hanging, which is an improvement!

At this point, I started thinking that my view function may generate lots of garbage, and the GC struggles to process everything at 60 FPS (default).

I wonder if Mint Tea can add something like has_diff : 'model -> 'model -> bool to t

https://github.com/leostera/minttea/blob/3e386136d315c60c16ea39b94789fbb7761003f5/minttea/app.ml#L1-L5

So that it can avoid calling view entirely if the model didn't change unlike the current implementation where we compare already rendered buffer:

https://github.com/leostera/minttea/blob/3e386136d315c60c16ea39b94789fbb7761003f5/minttea/renderer.ml#L26


Alternatively, exposing the fps setting from start may help app developers reduce their resource usage (I don't really need 60 fps)

https://github.com/leostera/minttea/blob/3e386136d315c60c16ea39b94789fbb7761003f5/minttea/minttea.ml#L9-L26

Originally posted by @chshersh in https://github.com/leostera/minttea/issues/38#issuecomment-2021312464

leostera avatar Mar 27 '24 12:03 leostera

@chshersh these are good ideas! super open to PRs to do a little diffing here and avoid unnecessary renders.

Also like the idea of passing in config for how Minttea should behave, and probably want it to be a little config record since I can imagine in the future apps that do not take user input (just render things out).

let () = 
  let config = Minttea.config ~fps:10 () in
  Minttea.start ~config ~initial_model app

This would let us add more options with sensible defaults while being backwards compatible.

leostera avatar Mar 27 '24 12:03 leostera

@leostera Agree with the idea of having a config 👍🏻

I can try experimenting with these ideas in my Mint Tea fork to see if they actually work for me (before contributing something that doesn't really fix the problem).

But it may take a while 😅 So don't wait for me!

chshersh avatar Mar 27 '24 16:03 chshersh