From 20754adc64542f241b9294d73f5bfbd08f7cbe57 Mon Sep 17 00:00:00 2001 From: arnonchen <52275454+Cyunong@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:41:00 +0800 Subject: [PATCH] fix(devtools): fix network debug information for ios in chrome devtool (#4112) --- framework/ios/base/executors/HippyJSExecutor.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/framework/ios/base/executors/HippyJSExecutor.mm b/framework/ios/base/executors/HippyJSExecutor.mm index 6b39a5f293c..ad540203868 100644 --- a/framework/ios/base/executors/HippyJSExecutor.mm +++ b/framework/ios/base/executors/HippyJSExecutor.mm @@ -265,9 +265,7 @@ - (void)injectDeviceInfoAsHippyNativeGlobal:(HippyBridge *)bridge context:(const std::shared_ptr &)context globalObject:(const std::shared_ptr &)globalObject { NSMutableDictionary *deviceInfo = [NSMutableDictionary dictionaryWithDictionary:[bridge deviceInfo]]; - NSString *deviceName = [[UIDevice currentDevice] name]; - NSString *clientId = HippyMD5Hash([NSString stringWithFormat:@"%@%p", deviceName, self]); - NSDictionary *debugInfo = @{@"Debug" : @{@"debugClientId" : clientId}}; + NSDictionary *debugInfo = @{@"Debug" : @{@"debugClientId" : [self getClientID]}}; [deviceInfo addEntriesFromDictionary:debugInfo]; auto key = context->CreateString(kHippyNativeGlobalKey); @@ -354,6 +352,12 @@ - (void)registerGetTurboModuleFuncToJS:(const std::shared_ptr &)cont #pragma mark - +- (NSString *)getClientID { + NSString *deviceName = [[UIDevice currentDevice] name]; + NSString *clientId = HippyMD5Hash([NSString stringWithFormat:@"%@%p", deviceName, self]); + return clientId; +} + - (void)setUriLoader:(std::weak_ptr)uriLoader { if (self.pScope->GetUriLoader().lock() != uriLoader.lock()) { self.pScope->SetUriLoader(uriLoader); @@ -769,9 +773,7 @@ - (NSString *)completeWSURLWithBridge:(HippyBridge *)bridge { devInfo.versionId = bundleURLProvider.versionId; devInfo.wsURL = bundleURLProvider.wsURL; } - NSString *deviceName = [[UIDevice currentDevice] name]; - NSString *clientId = HippyMD5Hash([NSString stringWithFormat:@"%@%p", deviceName, bridge]); - return [devInfo assembleFullWSURLWithClientId:clientId contextName:bridge.contextName]; + return [devInfo assembleFullWSURLWithClientId:[self getClientID] contextName:bridge.contextName]; }