5#include "flutter/runtime/dart_vm_initializer.h"
9#include "flutter/fml/logging.h"
10#include "flutter/fml/synchronization/shared_mutex.h"
11#include "flutter/fml/trace_event.h"
12#include "flutter/lib/ui/ui_dart_state.h"
13#include "flutter/lib/ui/window/platform_configuration.h"
22static std::atomic<bool> gDartInitialized;
24void LogUnhandledException(
Dart_Handle exception_handle,
26 const std::string
error =
28 const std::string stack_trace =
32 if (
state &&
state->unhandled_exception_callback()) {
45void ReportUnhandledException(
Dart_Handle exception_handle,
54 if (!
state || !
state->platform_configuration()) {
55 LogUnhandledException(exception_handle, stack_trace_handle);
58 auto on_error =
state->platform_configuration()->on_error();
62 args[0] = exception_handle;
63 args[1] = stack_trace_handle;
76 LogUnhandledException(exception_handle, stack_trace_handle);
83 bool enable_timeline_event_handler,
84 bool trace_systrace) {
92 gDartInitialized =
true;
95 if (enable_timeline_event_handler) {
96 if (!trace_systrace) {
104 []() -> int64_t {
return -1; });
133 gDartInitialized =
false;
142void DartVMInitializer::LogDartTimelineEvent(
const char* label,
144 int64_t timestamp1_or_async_id,
145 intptr_t flow_id_count,
146 const int64_t* flow_ids,
149 const char** argument_names,
150 const char** argument_values) {
151 if (gDartInitialized) {
154 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)
DART_EXPORT Dart_Handle Dart_ErrorGetStackTrace(Dart_Handle handle)
struct _Dart_Handle * Dart_Handle
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Initialize(Dart_InitializeParams *params)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Cleanup(void)
DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object)
const EmbeddedViewParams * params
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
#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)