Skip to content

Commit 214d473

Browse files
committed
workaround for #38
- disable vsync if kernel doesnt supply valid vblank timestamps - print a warning when vsync is disabled for this reason
1 parent 370c8e9 commit 214d473

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/flutter-pi.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,24 @@ bool init_application(void) {
11261126
.post_task_callback = &flutter_post_platform_task
11271127
}
11281128
};
1129-
flutter.args.vsync_callback = vsync_callback;
11301129

1130+
// only enable vsync if the kernel supplies valid vblank timestamps
1131+
uint64_t ns = 0;
1132+
ok = drmCrtcGetSequence(drm.fd, drm.crtc_id, NULL, &ns);
1133+
if (ok != 0) {
1134+
perror("Could not get last VBlank timestamp. drmCrtcGetSequence");
1135+
return false;
1136+
}
1137+
1138+
if (ns != 0) {
1139+
flutter.args.vsync_callback = vsync_callback;
1140+
} else {
1141+
fprintf(stderr,
1142+
"WARNING: Kernel didn't return a valid vblank timestamp.\n"
1143+
" VSync will be disabled.\n"
1144+
" See https://github.com/ardera/flutter-pi/issues/38 for more info.\n");
1145+
}
1146+
11311147
// spin up the engine
11321148
FlutterEngineResult _result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &flutter.renderer_config, &flutter.args, NULL, &engine);
11331149
if (_result != kSuccess) {

0 commit comments

Comments
 (0)