fix:when onDestroy call native plugin
This commit is contained in:
@@ -52,7 +52,6 @@ @implementation DoricJSEngine
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
_jsQueue = dispatch_queue_create("doric.jsengine", DISPATCH_QUEUE_SERIAL);
|
||||
_bridgeExtension = [[DoricBridgeExtension alloc] init];
|
||||
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
@@ -76,6 +75,8 @@ - (instancetype)init {
|
||||
dispatch_async(_jsQueue, ^() {
|
||||
self.timers = [[NSMutableDictionary alloc] init];
|
||||
self.registry = [[DoricRegistry alloc] init];
|
||||
self.bridgeExtension = [DoricBridgeExtension new];
|
||||
self.bridgeExtension.registry = self.registry;
|
||||
[self initJSEngine];
|
||||
[self initJSExecutor];
|
||||
[self initDoricEnvironment];
|
||||
|
@@ -21,10 +21,12 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "DoricRegistry.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DoricBridgeExtension : NSObject
|
||||
@property (nonatomic,weak) DoricRegistry *registry;
|
||||
|
||||
- (id)callNativeWithContextId:(NSString *)contextId module:(NSString *)module method:(NSString *)method callbackId:(NSString *)callbackId argument:(id)argument;
|
||||
@end
|
||||
|
||||
|
@@ -34,11 +34,7 @@ @implementation DoricBridgeExtension
|
||||
|
||||
- (id)callNativeWithContextId:(NSString *)contextId module:(NSString *)module method:(NSString *)method callbackId:(NSString *)callbackId argument:(id)argument {
|
||||
__strong DoricContext *context = [[DoricContextManager instance] getContext:contextId];
|
||||
if (!context) {
|
||||
return nil;
|
||||
}
|
||||
DoricRegistry *registry = context.driver.registry;
|
||||
Class pluginClass = [registry acquireNativePlugin:module];
|
||||
Class pluginClass = [self.registry acquireNativePlugin:module];
|
||||
DoricNativePlugin *nativePlugin = context.pluginInstanceMap[module];
|
||||
if (nativePlugin == nil) {
|
||||
nativePlugin = [(DoricNativePlugin *) [pluginClass alloc] initWithContext:context];
|
||||
@@ -72,6 +68,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
|
||||
NSMethodSignature *methodSignature = [target methodSignatureForSelector:selector];
|
||||
if (methodSignature) {
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];
|
||||
[invocation retainArguments];
|
||||
invocation.selector = selector;
|
||||
invocation.target = target;
|
||||
__weak __typeof__(self) _self = self;
|
||||
|
@@ -95,6 +95,7 @@ - (void)findClass:(Class)clz target:(id)target method:(NSString *)name promise:(
|
||||
NSMethodSignature *methodSignature = [target methodSignatureForSelector:selector];
|
||||
if (methodSignature) {
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];
|
||||
[invocation retainArguments];
|
||||
invocation.selector = selector;
|
||||
invocation.target = target;
|
||||
void *retValue;
|
||||
|
Reference in New Issue
Block a user