-
Notifications
You must be signed in to change notification settings - Fork 53
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
WriteBytesAsync with Uint8Array is slower than WebView1 counterpart. #3486
Comments
Thanks for reporting the issue. I've assigned this to a dev who can help follow up on this. |
I've opened a tracking bug for this. If it worked with the previous WebView1's WinRT projection we should look at supporting it for WebView2 - thanks! |
Adding on to this, passing a plain array using WebView1 - JavaScript Code:
Output 1:
Output 2:
WebView2 - JavaScript Code:
Output 1:
Output 2:
|
@david-risney Any update on this one? We are really looking forward to getting the read/write bytes issues fixed. |
Apologies, no good update yet. The WinRT API will be slow in this case at least because the byte array is in JS and the WinRT API is in the host app. The call to write the bytes will serialize all the bytes in the JS byte array, send the request to the host app, deserialize it into a native byte array and then actually call the WinRT API in the host app process. If you can keep the bytes in a WinRT object rather than a JS object then we won't have to serialize all bytes. I'm not sure if that's practical for this scenario. Alternatively perhaps instead of calling into the WinRT API to write the bytes you could use the shared buffer API to get the bytes to the native host app side without needing to serialize the byte array. |
Hi again, if the idea is to be able to read/write to some file in web content in WebView2 directly, you can now use the CoreWebView2.PostWebMessageAsJsonWithAdditionalObjects to share a FileSystemHandle directly to the web content from the app. Even a working WinRT API approach will not be as performant due to reasons stated above. |
This should be fixed in runtimes 125.0.2500.0+. Thanks! |
Description
Windows.Storage.FileIO.WriteBytesAsync
takes in a file and byteBuffer https://learn.microsoft.com/en-us/uwp/api/windows.storage.fileio.writebytesasync?view=winrt-22621. With WebView2, passingUint8Array(data) as unknown as number[]
results in Interface not supported error.It works when you pass a shallow copy of the object using, but we should be able to directly pass the Uint8Array as it was supported in webview1. Array slicing adds additional delay to write operations.
Version
SDK: 1.0.1777-prerelease
Framework: UWP/WinRT
OS: Win10
Repro Steps
Output
Screenshots
Additional context
This works as it is in webview1, regressed in webview2
AB#45973938
The text was updated successfully, but these errors were encountered: