Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
54 lines
1.6 KiB
Dart
54 lines
1.6 KiB
Dart
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'dart:ui';
|
|
|
|
import 'package:flutter/scheduler.dart';
|
|
|
|
/// Opt-in real-engine timings. No callbacks or I/O in ordinary app launches.
|
|
/// Set CUTDEX_FRAME_TIMINGS to a JSONL output path before launching the app.
|
|
void recordFrameTimingsFromEnvironment() {
|
|
final path = Platform.environment['CUTDEX_FRAME_TIMINGS'];
|
|
if (path == null || path.isEmpty) return;
|
|
final pending = <List<int>>[];
|
|
var writing = false;
|
|
var dropped = 0;
|
|
SchedulerBinding.instance.addTimingsCallback((frames) {
|
|
for (final frame in frames) {
|
|
if (pending.length >= 2048) {
|
|
dropped++;
|
|
continue;
|
|
}
|
|
pending.add([
|
|
frame.timestampInMicroseconds(FramePhase.vsyncStart),
|
|
frame.buildDuration.inMicroseconds,
|
|
frame.rasterDuration.inMicroseconds,
|
|
frame.totalSpan.inMicroseconds,
|
|
]);
|
|
}
|
|
});
|
|
Timer.periodic(const Duration(seconds: 2), (_) async {
|
|
if (writing || pending.isEmpty) return;
|
|
writing = true;
|
|
final batch = List<List<int>>.of(pending);
|
|
pending.clear();
|
|
final lost = dropped;
|
|
dropped = 0;
|
|
try {
|
|
await File(path).writeAsString(
|
|
'${jsonEncode({
|
|
'at': DateTime.now().toUtc().toIso8601String(),
|
|
'columns': ['vsyncUs', 'buildUs', 'rasterUs', 'totalUs'],
|
|
'dropped': lost,
|
|
'frames': batch,
|
|
})}\n',
|
|
mode: FileMode.append,
|
|
);
|
|
} on FileSystemException {
|
|
// Diagnostics must never interrupt editing (e.g. an unavailable drive).
|
|
} finally {
|
|
writing = false;
|
|
}
|
|
});
|
|
}
|