Flutter-desktop-embedding: throttle FlutterWindowLoop in linux implementation

Created on 21 May 2018  路  7Comments  路  Source: google/flutter-desktop-embedding

in the linux implementation the FlutterWindowLoop() due to the unregulated while infinite loop takes an high cpu percentange.
i think that flutter engine has some sort of flag to comunicate when a new frame is created so i think we can implement a event-based loop.

Most helpful comment

https://github.com/flutter/flutter/issues/16912 is the Flutter engine issue for changing message loop handling.

All 7 comments

__FlutterEngineFlushPendingTasksNow is related to receiving plugin messages, not drawing, so frame rate isn't the issue. We have no way of knowing how frequently plugins might message.

Significant changes are in the works to how the embedding API handles message loops, so I don't think there's any point in trying to tune the current implementation, which is basically a hack around the currently-missing functionality (note that we're calling a method with leading underscores and has a comment in the embedding API header that it will be removed).

with "i think that flutter engine has some sort of flag to comunicate when a new frame" i'm not referring to the "__FlutterEngineFlushPendingTasksNow" function but the functions used by dart part of flutter cuminicate with the engine asynchronously(with the message system of course).

Sorry, I'm not sure what communication system you are referring to, and I'm still not sure what relationship you think there is between frame availability and FlutterWindowLoop rate.

I think this suggestion might be about wanting to use glfwWaitEvents instead of glfwPollEvents inside FlutterWindowLoop. That might be tricky since the wait form might not know about the kind of events that __FlutterEngineFlushPendingTasksNow is meant to handle. If instead of __FlutterEngineFlushPendingTasksNow being called, the embedder could post an event to whatever glfwWaitEvents is monitoring, then we could probably implement a more efficient main loop.

Significant changes are in the works to how the embedding API handles message loops

@stuartmorgan
Is there an issue or a public channel where we can follow these discussions?

https://github.com/flutter/flutter/issues/16912 is the Flutter engine issue for changing message loop handling.

I am using this work-around currently:

    glfwWaitEventsTimeout(0.016);
    while (gtk_events_pending()) {
      gtk_main_iteration();
    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

GreenTigerEye picture GreenTigerEye  路  4Comments

eukreign picture eukreign  路  10Comments

handicraftsman picture handicraftsman  路  10Comments

Syleron picture Syleron  路  5Comments

pauldemarco picture pauldemarco  路  6Comments