diff --git a/engine/src/flutter/impeller/base/validation.cc b/engine/src/flutter/impeller/base/validation.cc index 94e35fc84f..d3f54a7ad8 100644 --- a/engine/src/flutter/impeller/base/validation.cc +++ b/engine/src/flutter/impeller/base/validation.cc @@ -11,6 +11,11 @@ namespace impeller { static std::atomic_int32_t sValidationLogsDisabledCount = 0; +static bool sValidationLogsAreFatal = false; + +void ImpellerValidationErrorsSetFatal(bool fatal) { + sValidationLogsAreFatal = fatal; +} ScopedValidationDisable::ScopedValidationDisable() { sValidationLogsDisabledCount++; @@ -24,12 +29,7 @@ ValidationLog::ValidationLog() = default; ValidationLog::~ValidationLog() { if (sValidationLogsDisabledCount <= 0) { -#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE) - FML_LOG(ERROR) << stream_.str(); - ImpellerValidationBreak(); -#else - FML_LOG(FATAL) << stream_.str(); -#endif + ImpellerValidationBreak(stream_.str().c_str()); } } @@ -37,10 +37,18 @@ std::ostream& ValidationLog::GetStream() { return stream_; } -void ImpellerValidationBreak() { - // Nothing to do. Exists for the debugger. - FML_LOG(ERROR) << "Break on " << __FUNCTION__ - << " to inspect point of failure."; +void ImpellerValidationBreak(const char* message) { +// Nothing to do. Exists for the debugger. +#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE + std::stringstream stream; + stream << "Break on '" << __FUNCTION__ + << "' to inspect point of failure: " << message; + if (sValidationLogsAreFatal) { + FML_LOG(FATAL) << stream.str(); + } else { + FML_LOG(INFO) << stream.str(); + } +#endif // FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE } } // namespace impeller diff --git a/engine/src/flutter/impeller/base/validation.h b/engine/src/flutter/impeller/base/validation.h index 18bb1b5b4a..e3e93ddd0b 100644 --- a/engine/src/flutter/impeller/base/validation.h +++ b/engine/src/flutter/impeller/base/validation.h @@ -24,7 +24,9 @@ class ValidationLog { FML_DISALLOW_COPY_ASSIGN_AND_MOVE(ValidationLog); }; -void ImpellerValidationBreak(); +void ImpellerValidationBreak(const char* message); + +void ImpellerValidationErrorsSetFatal(bool fatal); struct ScopedValidationDisable { ScopedValidationDisable(); diff --git a/engine/src/flutter/impeller/playground/playground_test.cc b/engine/src/flutter/impeller/playground/playground_test.cc index 95297cf3f9..613add3565 100644 --- a/engine/src/flutter/impeller/playground/playground_test.cc +++ b/engine/src/flutter/impeller/playground/playground_test.cc @@ -5,6 +5,7 @@ #include "flutter/fml/time/time_point.h" #include "impeller/base/timing.h" +#include "impeller/base/validation.h" #include "impeller/playground/playground_test.h" namespace impeller { @@ -25,6 +26,8 @@ void PlaygroundTest::SetUp() { return; } + ImpellerValidationErrorsSetFatal(true); + SetupContext(GetParam()); SetupWindow(); }