mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
725e034128
Summary: This module expects to compute main queue stuffs inside getConstants(), mark it so. This address crashes when running tests: ``` Main Thread Checker: UI API called on a background thread: -[UIApplication keyWindow] PID: 88318, TID: 22602153, Thread name: com.facebook.react.JavaScript, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 RNTester 0x0000000100beece8 RCTKeyWindow + 72 5 RNTester 0x0000000100beeee4 RCTForceTouchAvailable + 148 6 RNTester 0x0000000100c0b54d -[RCTPlatform getConstants] + 109 ``` Sample CI failure: https://circleci.com/gh/facebook/react-native/101079 Reviewed By: PeteTheHeat Differential Revision: D16198720 fbshipit-source-id: 272eaccf5027d0bf5b2838ed9623ae079fac148e
82 lines
1.8 KiB
Plaintext
82 lines
1.8 KiB
Plaintext
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTPlatform.h"
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
#import <React/RCTUtils.h>
|
|
#import <React/RCTVersion.h>
|
|
|
|
#import "CoreModulesPlugins.h"
|
|
|
|
using namespace facebook::react;
|
|
|
|
static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
|
switch(idiom) {
|
|
case UIUserInterfaceIdiomPhone:
|
|
return @"phone";
|
|
case UIUserInterfaceIdiomPad:
|
|
return @"pad";
|
|
case UIUserInterfaceIdiomTV:
|
|
return @"tv";
|
|
case UIUserInterfaceIdiomCarPlay:
|
|
return @"carplay";
|
|
default:
|
|
return @"unknown";
|
|
}
|
|
}
|
|
|
|
@interface RCTPlatform () <NativePlatformConstantsIOSSpec>
|
|
@end
|
|
|
|
@implementation RCTPlatform
|
|
|
|
RCT_EXPORT_MODULE(PlatformConstants)
|
|
|
|
+ (BOOL)requiresMainQueueSetup
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (dispatch_queue_t)methodQueue
|
|
{
|
|
return dispatch_get_main_queue();
|
|
}
|
|
|
|
// TODO: Use the generated struct return type.
|
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
|
{
|
|
return [self getConstants];
|
|
}
|
|
|
|
// TODO: Use the generated struct return type.
|
|
- (NSDictionary<NSString *, id> *)getConstants
|
|
{
|
|
UIDevice *device = [UIDevice currentDevice];
|
|
return @{
|
|
@"forceTouchAvailable": @(RCTForceTouchAvailable()),
|
|
@"osVersion": [device systemVersion],
|
|
@"systemName": [device systemName],
|
|
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
|
|
@"isTesting": @(RCTRunningInTestEnvironment()),
|
|
@"reactNativeVersion": RCTGetReactNativeVersion(),
|
|
};
|
|
}
|
|
|
|
- (std::shared_ptr<TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<JSCallInvoker>)jsInvoker
|
|
{
|
|
return std::make_shared<NativePlatformConstantsIOSSpecJSI>(self, jsInvoker);
|
|
}
|
|
|
|
@end
|
|
|
|
Class RCTPlatformCls(void) {
|
|
return RCTPlatform.class;
|
|
}
|