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

Configurable framerate and diff-rendering #46

Open
leostera opened this issue Mar 27, 2024 · 2 comments
Open

Configurable framerate and diff-rendering #46

leostera opened this issue Mar 27, 2024 · 2 comments

Comments

@leostera
Copy link
Owner

          @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

type 'model t = {
init : 'model -> Command.t;
update : Event.t -> 'model -> 'model * Command.t;
view : 'model -> string;
}

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

let same_as_last_flush t = t.buffer = t.last_render


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

let run ?(fps = 60) ~initial_model app =
let prog = Program.make ~app ~fps in
Program.run prog initial_model;
Logger.trace (fun f -> f "terminating")
let start app ~initial_model =
let module App = struct
let start () =
Logger.set_log_level None;
let pid =
spawn_link (fun () ->
run app ~initial_model;
Logger.trace (fun f -> f "about to shutdown");
shutdown ~status:0 ())
in
Ok pid
end in
Riot.start ~apps:[ (module Riot.Logger); (module App) ] ()

Originally posted by @chshersh in #38 (comment)

@leostera
Copy link
Owner Author

@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.

@chshersh
Copy link

@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!

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

2 participants