Skip to content

Commit b0f9231

Browse files
cbrackenloic-sharma
authored andcommitted
[iOS, macOS] Migrate from assert to FML_DCHECK (flutter#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.
1 parent b028838 commit b0f9231

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h"
66

7+
#include "flutter/fml/logging.h"
78
#include "flutter/lib/ui/plugins/callback_cache.h"
89

910
@implementation FlutterCallbackInformation
@@ -32,7 +33,7 @@ + (FlutterCallbackInformation*)lookupCallbackInformation:(int64_t)handle {
3233
}
3334

3435
+ (void)setCachePath:(NSString*)path {
35-
assert(path != nil);
36+
FML_DCHECK(path != nil);
3637
flutter::DartCallbackCache::SetCachePath([path UTF8String]);
3738
NSString* cache_path =
3839
[NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()];

shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.mm

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// found in the LICENSE file.
44

55
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h"
6+
7+
#include "flutter/fml/logging.h"
68
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
79
#import "flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h"
810

@@ -108,8 +110,8 @@ - (NSString*)charactersIgnoringModifiers API_AVAILABLE(ios(13.4)) {
108110
const char* characters,
109111
const char* charactersIgnoringModifiers)
110112
API_AVAILABLE(ios(13.4)) {
111-
assert(!(modifierFlags & kModifierFlagSidedMask) &&
112-
"iOS doesn't supply modifier side flags, so don't create events with them.");
113+
FML_DCHECK(!(modifierFlags & kModifierFlagSidedMask))
114+
<< "iOS doesn't supply modifier side flags, so don't create events with them.";
113115
UIKey* key =
114116
[[FakeUIKey alloc] initWithData:keyCode
115117
modifierFlags:modifierFlags

shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include <utility>
6-
75
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h"
86

7+
#include <utility>
8+
9+
#include "flutter/fml/logging.h"
910
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
1011
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
1112
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
@@ -243,7 +244,7 @@ static void ReplaceSemanticsObject(SemanticsObject* oldObject,
243244
SemanticsObject* newObject,
244245
NSMutableDictionary<NSNumber*, SemanticsObject*>* objects) {
245246
// `newObject` should represent the same id as `oldObject`.
246-
assert(oldObject.node.id == newObject.uid);
247+
FML_DCHECK(oldObject.node.id == newObject.uid);
247248
NSNumber* nodeId = @(oldObject.node.id);
248249
NSUInteger positionInChildlist = [oldObject.parent.children indexOfObject:oldObject];
249250
[[oldObject retain] autorelease];

shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
// found in the LICENSE file.
44

55
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"
6-
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"
76

87
#import <Metal/Metal.h>
8+
99
#include <algorithm>
1010

11+
#include "flutter/fml/logging.h"
12+
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"
13+
1114
@implementation FlutterSurfacePresentInfo
1215
@end
1316

@@ -75,7 +78,7 @@ - (FlutterSurface*)surfaceForSize:(CGSize)size {
7578
}
7679

7780
- (void)commit:(NSArray<FlutterSurfacePresentInfo*>*)surfaces {
78-
assert([NSThread isMainThread]);
81+
FML_DCHECK([NSThread isMainThread]);
7982

8083
// Release all unused back buffer surfaces and replace them with front surfaces.
8184
[_backBufferCache replaceSurfaces:_frontSurfaces];

shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.mm

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h"
2-
#import "fml/synchronization/waitable_event.h"
32

43
#import <QuartzCore/QuartzCore.h>
54

65
#include <mutex>
76
#include <vector>
87

8+
#import "flutter/fml/logging.h"
9+
#import "flutter/fml/synchronization/waitable_event.h"
10+
911
@interface FlutterThreadSynchronizer () {
1012
std::mutex _mutex;
1113
BOOL _shuttingDown;
@@ -23,7 +25,7 @@ @interface FlutterThreadSynchronizer () {
2325
@implementation FlutterThreadSynchronizer
2426

2527
- (void)drain {
26-
assert([NSThread isMainThread]);
28+
FML_DCHECK([NSThread isMainThread]);
2729

2830
[CATransaction begin];
2931
[CATransaction setDisableActions:YES];

0 commit comments

Comments
 (0)