[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"
#include "flutter/fml/logging.h"
#include "flutter/lib/ui/plugins/callback_cache.h"
@implementation FlutterCallbackInformation
@ -32,7 +33,7 @@
}
+ (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()];

View File

@ -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"
@ -108,8 +110,8 @@ FlutterUIPressProxy* keyEventWithPhase(UIPressPhase phase,
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

View File

@ -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"
@ -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];

View File

@ -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
@ -75,7 +78,7 @@
}
- (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];

View File

@ -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;
@ -23,7 +25,7 @@
@implementation FlutterThreadSynchronizer
- (void)drain {
assert([NSThread isMainThread]);
FML_DCHECK([NSThread isMainThread]);
[CATransaction begin];
[CATransaction setDisableActions:YES];