21static std::atomic<bool> gDartInitialized;
23void LogUnhandledException(Dart_Handle exception_handle,
24 Dart_Handle stack_trace_handle) {
25 const std::string
error =
27 const std::string stack_trace =
31 if (state && state->unhandled_exception_callback()) {
32 auto callback = state->unhandled_exception_callback();
40 FML_LOG(ERROR) <<
"Unhandled Exception: " <<
error << std::endl
44void ReportUnhandledException(Dart_Handle exception_handle,
45 Dart_Handle stack_trace_handle) {
53 if (!state || !state->platform_configuration()) {
54 LogUnhandledException(exception_handle, stack_trace_handle);
57 auto on_error = state->platform_configuration()->on_error();
61 args[0] = exception_handle;
62 args[1] = stack_trace_handle;
63 Dart_Handle on_error_result = Dart_InvokeClosure(on_error, 2,
args);
66 if (Dart_IsError(on_error_result)) {
67 LogUnhandledException(Dart_ErrorGetException(on_error_result),
68 Dart_ErrorGetStackTrace(on_error_result));
75 LogUnhandledException(exception_handle, stack_trace_handle);
82 bool enable_timeline_event_handler,
83 bool trace_systrace) {
88 FML_LOG(FATAL) <<
"Error while initializing the Dart VM: " <<
error;
91 gDartInitialized =
true;
94 if (enable_timeline_event_handler) {
95 if (!trace_systrace) {
103 []() -> int64_t {
return -1; });
132 gDartInitialized =
false;
134 char*
error = Dart_Cleanup();
136 FML_LOG(FATAL) <<
"Error while cleaning up the Dart VM: " <<
error;
141void DartVMInitializer::LogDartTimelineEvent(
const char* label,
143 int64_t timestamp1_or_async_id,
144 intptr_t flow_id_count,
145 const int64_t* flow_ids,
146 Dart_Timeline_Event_Type
type,
148 const char** argument_names,
149 const char** argument_values) {
150 if (gDartInitialized) {
151 Dart_RecordTimelineEvent(label, timestamp0, timestamp1_or_async_id,
153 argument_names, argument_values);
static void Initialize(Dart_InitializeParams *params, bool enable_timeline_event_handler, bool trace_systrace)
static UIDartState * Current()
static void SetClockSource(ClockSource source)
const EmbeddedViewParams * params
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
FlutterDesktopBinaryReply callback
#define FML_LOG(severity)
#define FML_DCHECK(condition)
fml::TimePoint DartTimelineTicksSinceEpoch()
void TraceSetTimelineEventHandler(TimelineEventHandler handler)
void TraceSetTimelineMicrosSource(TimelineMicrosSource source)
void SetUnhandledExceptionReporter(DartError::UnhandledExceptionReporter reporter)
std::string StdStringFromDart(Dart_Handle handle)