Title: [290510] trunk/Source/_javascript_Core
- Revision
- 290510
- Author
- [email protected]
- Date
- 2022-02-25 08:32:10 -0800 (Fri, 25 Feb 2022)
Log Message
Web Inspector: [Cocoa] Split remote inspector message data into smaller chunks for large messages
https://bugs.webkit.org/show_bug.cgi?id=237110
<rdar://89364487>
Reviewed by Devin Rousso.
Messages over 2 MiB will now be split into multiple chunks, which allows us to not exceed any receiving daemon
process' memory limit under otherwise normal conditions. 2 MiB was chosen as a balance between not having to
split most messages at all and making sure that the messages (and any copies made during the relaying of the
messages) do not exceed the memory limits of the receiving daemon process.
In order to prevent us from sending chunked messages to a process that doesn't support them we check for a flag
to enable this functionality during connection setup.
* inspector/remote/RemoteInspector.h:
* inspector/remote/RemoteInspectorConstants.h:
* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::sendMessageToRemote):
(Inspector::RemoteInspector::receivedSetupMessage):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (290509 => 290510)
--- trunk/Source/_javascript_Core/ChangeLog 2022-02-25 16:23:12 UTC (rev 290509)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-02-25 16:32:10 UTC (rev 290510)
@@ -1,3 +1,25 @@
+2022-02-25 Patrick Angle <[email protected]>
+
+ Web Inspector: [Cocoa] Split remote inspector message data into smaller chunks for large messages
+ https://bugs.webkit.org/show_bug.cgi?id=237110
+ <rdar://89364487>
+
+ Reviewed by Devin Rousso.
+
+ Messages over 2 MiB will now be split into multiple chunks, which allows us to not exceed any receiving daemon
+ process' memory limit under otherwise normal conditions. 2 MiB was chosen as a balance between not having to
+ split most messages at all and making sure that the messages (and any copies made during the relaying of the
+ messages) do not exceed the memory limits of the receiving daemon process.
+
+ In order to prevent us from sending chunked messages to a process that doesn't support them we check for a flag
+ to enable this functionality during connection setup.
+
+ * inspector/remote/RemoteInspector.h:
+ * inspector/remote/RemoteInspectorConstants.h:
+ * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+ (Inspector::RemoteInspector::sendMessageToRemote):
+ (Inspector::RemoteInspector::receivedSetupMessage):
+
2022-02-24 Chris Dumez <[email protected]>
[Cocoa] Only clear ICU cache when time zone is changed
Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h (290509 => 290510)
--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h 2022-02-25 16:23:12 UTC (rev 290509)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h 2022-02-25 16:32:10 UTC (rev 290510)
@@ -290,6 +290,7 @@
ProcessID m_parentProcessIdentifier { 0 };
#if PLATFORM(COCOA)
RetainPtr<CFDataRef> m_parentProcessAuditData;
+ bool m_messageDataTypeChunkSupported { false };
#endif
bool m_shouldSendParentProcessInformation { false };
bool m_automaticInspectionEnabled { false };
Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h (290509 => 290510)
--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h 2022-02-25 16:23:12 UTC (rev 290509)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h 2022-02-25 16:32:10 UTC (rev 290510)
@@ -56,6 +56,7 @@
#define WIRUserInfoKey @"WIRUserInfoKey"
#define WIRApplicationDictionaryKey @"WIRApplicationDictionaryKey"
#define WIRMessageDataKey @"WIRMessageDataKey"
+#define WIRMessageDataTypeKey @"WIRMessageDataTypeKey"
#define WIRApplicationGetListingMessage @"WIRApplicationGetListingMessage"
#define WIRApplicationWakeUpDebuggablesMessage @"WIRApplicationWakeUpDebuggablesMessage"
#define WIRIndicateMessage @"WIRIndicateMessage"
@@ -82,7 +83,13 @@
#define WIRTypeWeb @"WIRTypeWeb" // COMPATIBILITY (iOS 13): "Web" was split into "Page" (WebCore::Page) and "WebPage" (WebKit::WebPageProxy).
#define WIRTypeWebPage @"WIRTypeWebPage"
#define WIRAutomaticallyPause @"WIRAutomaticallyPause"
+#define WIRMessageDataTypeChunkSupportedKey @"WIRMessageDataTypeChunkSupportedKey"
+// Allowed values for WIRMessageDataTypeKey.
+#define WIRMessageDataTypeFull @"WIRMessageDataTypeFull"
+#define WIRMessageDataTypeChunk @"WIRMessageDataTypeChunk"
+#define WIRMessageDataTypeFinalChunk @"WIRMessageDataTypeFinalChunk"
+
// Allowed values for WIRAutomationAvailabilityKey.
#define WIRAutomationAvailabilityNotAvailable @"WIRAutomationAvailabilityNotAvailable"
#define WIRAutomationAvailabilityAvailable @"WIRAutomationAvailabilityAvailable"
Modified: trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm (290509 => 290510)
--- trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm 2022-02-25 16:23:12 UTC (rev 290509)
+++ trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm 2022-02-25 16:32:10 UTC (rev 290510)
@@ -204,13 +204,33 @@
if (!targetConnection)
return;
- NSDictionary *userInfo = @{
- WIRRawDataKey: [static_cast<NSString *>(message) dataUsingEncoding:NSUTF8StringEncoding],
- WIRConnectionIdentifierKey: targetConnection->connectionIdentifier(),
- WIRDestinationKey: targetConnection->destination()
- };
+ NSData *messageData = [static_cast<NSString *>(message) dataUsingEncoding:NSUTF8StringEncoding];
+ NSUInteger messageLength = messageData.length;
+ const NSUInteger maxChunkSize = 2 * 1024 * 1024; // 2 Mebibytes
- m_relayConnection->sendMessage(WIRRawDataMessage, userInfo);
+ if (!m_messageDataTypeChunkSupported || messageLength < maxChunkSize) {
+ m_relayConnection->sendMessage(WIRRawDataMessage, @{
+ WIRRawDataKey: messageData,
+ WIRMessageDataTypeKey: WIRMessageDataTypeFull,
+ WIRConnectionIdentifierKey: targetConnection->connectionIdentifier(),
+ WIRDestinationKey: targetConnection->destination()
+ });
+ return;
+ }
+
+ for (NSUInteger offset = 0; offset < messageLength; offset += maxChunkSize) {
+ @autoreleasepool {
+ NSUInteger currentChunkSize = std::min(messageLength - offset, maxChunkSize);
+ NSString *type = offset + currentChunkSize == messageLength ? WIRMessageDataTypeFinalChunk : WIRMessageDataTypeChunk;
+
+ m_relayConnection->sendMessage(WIRRawDataMessage, @{
+ WIRRawDataKey: [messageData subdataWithRange:NSMakeRange(offset, currentChunkSize)],
+ WIRMessageDataTypeKey: type,
+ WIRConnectionIdentifierKey: targetConnection->connectionIdentifier(),
+ WIRDestinationKey: targetConnection->destination()
+ });
+ }
+ }
}
void RemoteInspector::start()
@@ -527,6 +547,11 @@
BAIL_IF_UNEXPECTED_TYPE_ALLOWING_NIL(automaticallyPauseNumber, [NSNumber class]);
BOOL automaticallyPause = automaticallyPauseNumber.boolValue;
+ NSNumber *messageDataTypeChunkSupportedNumber = userInfo[WIRMessageDataTypeChunkSupportedKey];
+ convertNSNullToNil(messageDataTypeChunkSupportedNumber);
+ BAIL_IF_UNEXPECTED_TYPE_ALLOWING_NIL(messageDataTypeChunkSupportedNumber, [NSNumber class]);
+ m_messageDataTypeChunkSupported = messageDataTypeChunkSupportedNumber.boolValue;
+
TargetID targetIdentifier = targetIdentifierNumber.unsignedIntValue;
if (!targetIdentifier)
return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes