-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] [bidi] Serialize base64 encoded string directly to bytes #16203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dotnet] [bidi] Serialize base64 encoded string directly to bytes #16203
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
User description
💥 What does this PR do?
There is no reason to keep base64 encoded string as
System.String
type, in any case it will be materialized tobyte[]
. So let's do it.💡 Additional Considerations
It also reduces memory allocation, capturing screenshot: before 824.87 KB, after 655.86 KB
🔄 Types of changes
PR Type
Enhancement
Description
Replace base64 string handling with direct byte arrays
Reduce memory allocation by ~20% for screenshot operations
Update BiDi commands to use
ReadOnlyMemory<byte>
typeEliminate unnecessary base64 string conversions
Diagram Walkthrough
File Walkthrough
CaptureScreenshotCommand.cs
Update screenshot result to use byte memory
dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshotCommand.cs
CaptureScreenshotResult.Data
fromstring
toReadOnlyMemory
ToByteArray()
to use direct array conversionSystem
namespace importPrintCommand.cs
Update print result to use byte memory
dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs
PrintResult.Data
fromstring
toReadOnlyMemory
ToByteArray()
method implementationBytesValue.cs
Update bytes value to use memory type
dotnet/src/webdriver/BiDi/Network/BytesValue.cs
Base64BytesValue.Value
fromstring
toReadOnlyMemory
InstallCommand.cs
Update extension data to use byte memory
dotnet/src/webdriver/BiDi/WebExtension/InstallCommand.cs
ExtensionBase64Encoded.Value
fromstring
toReadOnlyMemory
System
namespace importWebExtensionTest.cs
Update test for direct byte usage
dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs