[iOS, macOS] Migrate from assert to FML_DCHECK (flutter/engine#38368)

Eliminates raw C asserts in the iOS and macOS embedders, replacing them
with FML_DCHECK for consistency with the rest of the codebase.

No semantic change so no changes to tests.
This commit is contained in:
Chris Bracken
2022-12-16 19:07:16 -08:00
committed by GitHub
parent 29c3e97f45
commit 1571befea8
5 changed files with 19 additions and 10 deletions

View File

@@ -4,6 +4,7 @@
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h"
#include "flutter/fml/logging.h"
#include "flutter/lib/ui/plugins/callback_cache.h" #include "flutter/lib/ui/plugins/callback_cache.h"
@implementation FlutterCallbackInformation @implementation FlutterCallbackInformation
@@ -32,7 +33,7 @@
} }
+ (void)setCachePath:(NSString*)path { + (void)setCachePath:(NSString*)path {
assert(path != nil); FML_DCHECK(path != nil);
flutter::DartCallbackCache::SetCachePath([path UTF8String]); flutter::DartCallbackCache::SetCachePath([path UTF8String]);
NSString* cache_path = NSString* cache_path =
[NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()]; [NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()];

View File

@@ -3,6 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h"
#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h"
@@ -108,8 +110,8 @@ FlutterUIPressProxy* keyEventWithPhase(UIPressPhase phase,
const char* characters, const char* characters,
const char* charactersIgnoringModifiers) const char* charactersIgnoringModifiers)
API_AVAILABLE(ios(13.4)) { API_AVAILABLE(ios(13.4)) {
assert(!(modifierFlags & kModifierFlagSidedMask) && FML_DCHECK(!(modifierFlags & kModifierFlagSidedMask))
"iOS doesn't supply modifier side flags, so don't create events with them."); << "iOS doesn't supply modifier side flags, so don't create events with them.";
UIKey* key = UIKey* key =
[[FakeUIKey alloc] initWithData:keyCode [[FakeUIKey alloc] initWithData:keyCode
modifierFlags:modifierFlags modifierFlags:modifierFlags

View File

@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <utility>
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h" #import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h"
#include <utility>
#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h" #import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
@@ -243,7 +244,7 @@ static void ReplaceSemanticsObject(SemanticsObject* oldObject,
SemanticsObject* newObject, SemanticsObject* newObject,
NSMutableDictionary<NSNumber*, SemanticsObject*>* objects) { NSMutableDictionary<NSNumber*, SemanticsObject*>* objects) {
// `newObject` should represent the same id as `oldObject`. // `newObject` should represent the same id as `oldObject`.
assert(oldObject.node.id == newObject.uid); FML_DCHECK(oldObject.node.id == newObject.uid);
NSNumber* nodeId = @(oldObject.node.id); NSNumber* nodeId = @(oldObject.node.id);
NSUInteger positionInChildlist = [oldObject.parent.children indexOfObject:oldObject]; NSUInteger positionInChildlist = [oldObject.parent.children indexOfObject:oldObject];
[[oldObject retain] autorelease]; [[oldObject retain] autorelease];

View File

@@ -3,11 +3,14 @@
// found in the LICENSE file. // found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"
#import <Metal/Metal.h> #import <Metal/Metal.h>
#include <algorithm> #include <algorithm>
#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"
@implementation FlutterSurfacePresentInfo @implementation FlutterSurfacePresentInfo
@end @end
@@ -75,7 +78,7 @@
} }
- (void)commit:(NSArray<FlutterSurfacePresentInfo*>*)surfaces { - (void)commit:(NSArray<FlutterSurfacePresentInfo*>*)surfaces {
assert([NSThread isMainThread]); FML_DCHECK([NSThread isMainThread]);
// Release all unused back buffer surfaces and replace them with front surfaces. // Release all unused back buffer surfaces and replace them with front surfaces.
[_backBufferCache replaceSurfaces:_frontSurfaces]; [_backBufferCache replaceSurfaces:_frontSurfaces];

View File

@@ -1,11 +1,13 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h"
#import "fml/synchronization/waitable_event.h"
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
#import "flutter/fml/logging.h"
#import "flutter/fml/synchronization/waitable_event.h"
@interface FlutterThreadSynchronizer () { @interface FlutterThreadSynchronizer () {
std::mutex _mutex; std::mutex _mutex;
BOOL _shuttingDown; BOOL _shuttingDown;
@@ -23,7 +25,7 @@
@implementation FlutterThreadSynchronizer @implementation FlutterThreadSynchronizer
- (void)drain { - (void)drain {
assert([NSThread isMainThread]); FML_DCHECK([NSThread isMainThread]);
[CATransaction begin]; [CATransaction begin];
[CATransaction setDisableActions:YES]; [CATransaction setDisableActions:YES];