Thread the JSI runtime descriptor up into the RCTDevMenu title
Reviewed By: javache Differential Revision: D5643014 fbshipit-source-id: 977be5729c57c0d01ff67b268031ad6fdbf88a07
This commit is contained in:
parent
7d4a5b67d4
commit
d48f08cad6
|
@ -63,6 +63,7 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) {
|
|||
@synthesize loading = _loading;
|
||||
@synthesize valid = _valid;
|
||||
@synthesize performanceLogger = _performanceLogger;
|
||||
@synthesize bridgeDescription = _bridgeDescription;
|
||||
|
||||
- (instancetype)initWithParentBridge:(RCTBridge *)bridge
|
||||
{
|
||||
|
|
|
@ -35,6 +35,9 @@ RCT_EXTERN void RCTVerifyAllModulesExported(NSArray *extraModules);
|
|||
@property (nonatomic, assign) CFMutableDictionaryRef flowIDMap;
|
||||
@property (nonatomic, strong) NSLock *flowIDMapLock;
|
||||
|
||||
// Used by RCTDevMenu
|
||||
@property (nonatomic, copy) NSString *bridgeDescription;
|
||||
|
||||
+ (instancetype)currentBridge;
|
||||
+ (void)setCurrentBridge:(RCTBridge *)bridge;
|
||||
|
||||
|
|
|
@ -72,6 +72,30 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) {
|
|||
RCTBridgeFieldCallID,
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
class GetDescAdapter : public JSExecutorFactory {
|
||||
public:
|
||||
GetDescAdapter(RCTCxxBridge *bridge, std::shared_ptr<JSExecutorFactory> factory)
|
||||
: bridge_(bridge)
|
||||
, factory_(factory) {}
|
||||
std::unique_ptr<JSExecutor> createJSExecutor(
|
||||
std::shared_ptr<ExecutorDelegate> delegate,
|
||||
std::shared_ptr<MessageQueueThread> jsQueue) override {
|
||||
auto ret = factory_->createJSExecutor(delegate, jsQueue);
|
||||
bridge_.bridgeDescription =
|
||||
[NSString stringWithFormat:@"RCTCxxBridge %s",
|
||||
ret->getDescription().c_str()];
|
||||
return std::move(ret);
|
||||
}
|
||||
|
||||
private:
|
||||
RCTCxxBridge *bridge_;
|
||||
std::shared_ptr<JSExecutorFactory> factory_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static bool isRAMBundle(NSData *script) {
|
||||
BundleHeader header;
|
||||
[script getBytes:&header length:sizeof(header)];
|
||||
|
@ -154,6 +178,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||
@synthesize loading = _loading;
|
||||
@synthesize valid = _valid;
|
||||
@synthesize performanceLogger = _performanceLogger;
|
||||
@synthesize bridgeDescription = _bridgeDescription;
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
|
@ -491,6 +516,10 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTCxxBridge initializeBridge:]", nil);
|
||||
// This can only be false if the bridge was invalidated before startup completed
|
||||
if (_reactInstance) {
|
||||
#if RCT_DEV
|
||||
executorFactory = std::make_shared<GetDescAdapter>(self, executorFactory);
|
||||
#endif
|
||||
|
||||
// This is async, but any calls into JS are blocked by the m_syncReady CV in Instance
|
||||
_reactInstance->initializeBridge(
|
||||
std::unique_ptr<RCTInstanceCallback>(new RCTInstanceCallback(self)),
|
||||
|
|
|
@ -117,6 +117,10 @@ public:
|
|||
callback:m_errorBlock];
|
||||
}
|
||||
|
||||
virtual std::string getDescription() override {
|
||||
return [NSStringFromClass([m_jse class]) UTF8String];
|
||||
}
|
||||
|
||||
private:
|
||||
id<RCTJavaScriptExecutor> m_jse;
|
||||
RCTJavaScriptCompleteBlock m_errorBlock;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#import "RCTDevMenu.h"
|
||||
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTDevSettings.h"
|
||||
#import "RCTKeyCommands.h"
|
||||
#import "RCTLog.h"
|
||||
|
@ -259,7 +260,11 @@ RCT_EXPORT_METHOD(show)
|
|||
return;
|
||||
}
|
||||
|
||||
NSString *title = [NSString stringWithFormat:@"React Native: Development (%@)", [_bridge class]];
|
||||
NSString *desc = _bridge.bridgeDescription;
|
||||
if (desc.length == 0) {
|
||||
desc = NSStringFromClass([_bridge class]);
|
||||
}
|
||||
NSString *title = [NSString stringWithFormat:@"React Native: Development (%@)", desc];
|
||||
// On larger devices we don't have an anchor point for the action sheet
|
||||
UIAlertControllerStyle style = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ? UIAlertControllerStyleActionSheet : UIAlertControllerStyleAlert;
|
||||
_actionSheet = [UIAlertController alertControllerWithTitle:title
|
||||
|
|
|
@ -114,4 +114,8 @@ void ProxyExecutor::setGlobalVariable(std::string propName,
|
|||
jni::make_jstring(jsonValue->c_str()).get());
|
||||
}
|
||||
|
||||
std::string ProxyExecutor::getDescription() {
|
||||
return "Chrome";
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
virtual void setGlobalVariable(
|
||||
std::string propName,
|
||||
std::unique_ptr<const JSBigString> jsonValue) override;
|
||||
virtual std::string getDescription() override;
|
||||
|
||||
private:
|
||||
jni::global_ref<jobject> m_executor;
|
||||
|
|
|
@ -509,6 +509,18 @@ void JSCExecutor::setGlobalVariable(std::string propName, std::unique_ptr<const
|
|||
}
|
||||
}
|
||||
|
||||
std::string JSCExecutor::getDescription() {
|
||||
#if defined(__APPLE__)
|
||||
if (isCustomJSCPtr(m_context)) {
|
||||
return "Custom JSC";
|
||||
} else {
|
||||
return "System JSC";
|
||||
}
|
||||
#else
|
||||
return "JSC";
|
||||
#endif
|
||||
}
|
||||
|
||||
String JSCExecutor::adoptString(std::unique_ptr<const JSBigString> script) {
|
||||
#if defined(WITH_FBJSCEXTENSIONS)
|
||||
const JSBigString* string = script.release();
|
||||
|
|
|
@ -88,6 +88,8 @@ public:
|
|||
std::string propName,
|
||||
std::unique_ptr<const JSBigString> jsonValue) override;
|
||||
|
||||
virtual std::string getDescription() override;
|
||||
|
||||
virtual void* getJavaScriptContext() override;
|
||||
|
||||
#ifdef WITH_JSC_MEMORY_PRESSURE
|
||||
|
|
|
@ -73,6 +73,13 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description is displayed in the dev menu, if there is one in
|
||||
* this build. There is a default, but if this method returns a
|
||||
* non-empty string, it will be used instead.
|
||||
*/
|
||||
virtual std::string getDescription() = 0;
|
||||
|
||||
virtual void handleMemoryPressure(int pressureLevel) {}
|
||||
|
||||
virtual void destroy() {}
|
||||
|
|
Loading…
Reference in New Issue