[ReactNative][Profiler] Fix initialize extra call + add popup
Summary: @public When the profile is initialized, it automatically hooks into every method of the bridge modules, that was causing `+initialize` to be called twice. Also add a popup to notify the user that the profile has been created. Test Plan: Run the UIExplorer, start the profiler, try to rage shake to open the dev menu again. It should now work, and show an alertview with some information once the profile is stopped.
This commit is contained in:
Родитель
a8011f283d
Коммит
3d6ffcf903
|
@ -1529,6 +1529,12 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(__unused NSString *)module
|
|||
^(__unused NSData *data, __unused NSURLResponse *response, NSError *error) {
|
||||
if (error) {
|
||||
RCTLogError(@"%@", error.localizedDescription);
|
||||
} else {
|
||||
[[[UIAlertView alloc] initWithTitle:@"Profile"
|
||||
message:@"The profile has been generated, check the dev server log for instructions."
|
||||
delegate:nil
|
||||
cancelButtonTitle:@"OK"
|
||||
otherButtonTitles:nil] show];
|
||||
}
|
||||
}];
|
||||
|
||||
|
|
|
@ -172,6 +172,8 @@ static void RCTProfileHookModules(RCTBridge *bridge)
|
|||
}
|
||||
free(methods);
|
||||
|
||||
class_replaceMethod(object_getClass(proxyClass), @selector(initialize), imp_implementationWithBlock(^{}), "v@:");
|
||||
|
||||
for (Class cls in @[proxyClass, object_getClass(proxyClass)]) {
|
||||
Method oldImp = class_getInstanceMethod(cls, @selector(class));
|
||||
class_replaceMethod(cls, @selector(class), imp_implementationWithBlock(^{ return moduleClass; }), method_getTypeEncoding(oldImp));
|
||||
|
|
Загрузка…
Ссылка в новой задаче