Title: [290939] branches/safari-613-branch/Source/_javascript_Core
- Revision
- 290939
- Author
- [email protected]
- Date
- 2022-03-07 14:10:26 -0800 (Mon, 07 Mar 2022)
Log Message
Cherry-pick r290510. rdar://problem/89364487
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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-613-branch/Source/_javascript_Core/ChangeLog (290938 => 290939)
--- branches/safari-613-branch/Source/_javascript_Core/ChangeLog 2022-03-07 22:10:23 UTC (rev 290938)
+++ branches/safari-613-branch/Source/_javascript_Core/ChangeLog 2022-03-07 22:10:26 UTC (rev 290939)
@@ -1,5 +1,54 @@
2022-03-07 Russell Epstein <[email protected]>
+ Cherry-pick r290510. rdar://problem/89364487
+
+ 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):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 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-03-07 Russell Epstein <[email protected]>
+
Cherry-pick r290265. rdar://problem/88258776
[JSC] Add explicit exception check after appendWithoutSideEffects
Modified: branches/safari-613-branch/Source/_javascript_Core/inspector/remote/RemoteInspector.h (290938 => 290939)
--- branches/safari-613-branch/Source/_javascript_Core/inspector/remote/RemoteInspector.h 2022-03-07 22:10:23 UTC (rev 290938)
+++ branches/safari-613-branch/Source/_javascript_Core/inspector/remote/RemoteInspector.h 2022-03-07 22:10:26 UTC (rev 290939)
@@ -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: branches/safari-613-branch/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h (290938 => 290939)
--- branches/safari-613-branch/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h 2022-03-07 22:10:23 UTC (rev 290938)
+++ branches/safari-613-branch/Source/_javascript_Core/inspector/remote/RemoteInspectorConstants.h 2022-03-07 22:10:26 UTC (rev 290939)
@@ -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: branches/safari-613-branch/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm (290938 => 290939)
--- branches/safari-613-branch/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm 2022-03-07 22:10:23 UTC (rev 290938)
+++ branches/safari-613-branch/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm 2022-03-07 22:10:26 UTC (rev 290939)
@@ -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