Skip to content

Commit

Permalink
[iOS, macOS] Migrate from assert to FML_DCHECK (flutter#38368)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cbracken authored and loic-sharma committed Jan 3, 2023
1 parent b028838 commit b0f9231
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Expand Up @@ -4,6 +4,7 @@

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

#include "flutter/fml/logging.h"
#include "flutter/lib/ui/plugins/callback_cache.h"

@implementation FlutterCallbackInformation
Expand Down Expand Up @@ -32,7 +33,7 @@ + (FlutterCallbackInformation*)lookupCallbackInformation:(int64_t)handle {
}

+ (void)setCachePath:(NSString*)path {
assert(path != nil);
FML_DCHECK(path != nil);
flutter::DartCallbackCache::SetCachePath([path UTF8String]);
NSString* cache_path =
[NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()];
Expand Down
Expand Up @@ -3,6 +3,8 @@
// found in the LICENSE file.

#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/ios/framework/Source/KeyCodeMap_Internal.h"

Expand Down Expand Up @@ -108,8 +110,8 @@ - (NSString*)charactersIgnoringModifiers API_AVAILABLE(ios(13.4)) {
const char* characters,
const char* charactersIgnoringModifiers)
API_AVAILABLE(ios(13.4)) {
assert(!(modifierFlags & kModifierFlagSidedMask) &&
"iOS doesn't supply modifier side flags, so don't create events with them.");
FML_DCHECK(!(modifierFlags & kModifierFlagSidedMask))
<< "iOS doesn't supply modifier side flags, so don't create events with them.";
UIKey* key =
[[FakeUIKey alloc] initWithData:keyCode
modifierFlags:modifierFlags
Expand Down
Expand Up @@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <utility>

#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/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
Expand Down Expand Up @@ -243,7 +244,7 @@ static void ReplaceSemanticsObject(SemanticsObject* oldObject,
SemanticsObject* newObject,
NSMutableDictionary<NSNumber*, SemanticsObject*>* objects) {
// `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);
NSUInteger positionInChildlist = [oldObject.parent.children indexOfObject:oldObject];
[[oldObject retain] autorelease];
Expand Down
Expand Up @@ -3,11 +3,14 @@
// found in the LICENSE file.

#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"

#import <Metal/Metal.h>

#include <algorithm>

#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"

@implementation FlutterSurfacePresentInfo
@end

Expand Down Expand Up @@ -75,7 +78,7 @@ - (FlutterSurface*)surfaceForSize:(CGSize)size {
}

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

// Release all unused back buffer surfaces and replace them with front surfaces.
[_backBufferCache replaceSurfaces:_frontSurfaces];
Expand Down
@@ -1,11 +1,13 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h"
#import "fml/synchronization/waitable_event.h"

#import <QuartzCore/QuartzCore.h>

#include <mutex>
#include <vector>

#import "flutter/fml/logging.h"
#import "flutter/fml/synchronization/waitable_event.h"

@interface FlutterThreadSynchronizer () {
std::mutex _mutex;
BOOL _shuttingDown;
Expand All @@ -23,7 +25,7 @@ @interface FlutterThreadSynchronizer () {
@implementation FlutterThreadSynchronizer

- (void)drain {
assert([NSThread isMainThread]);
FML_DCHECK([NSThread isMainThread]);

[CATransaction begin];
[CATransaction setDisableActions:YES];
Expand Down

0 comments on commit b0f9231

Please sign in to comment.