Skip to content

Configurable framerate and diff-rendering #46

@leostera

Description

@leostera
          @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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions