GetContentAsync() of the event WebResourceResponseReceived event throws a ComException, when posting content that exceeds 123290000 bytes (files of about 125 MB size).
This happens for WinForms and WPF apps, and it happens for the latest SDK 1.0.2210.55, but for an older SDK 1.0.1587.40 as well.
I have not tested it with other runtimes than 120.0.2210.121
It is reproducable for me, so that it works every time for a smaller post size, e.g. 123289000 bytes, and it throws the exception every time I post the longer content with at least 123290000 bytes.
since I have a workaround the importance is moderate for me, but for other use cases it could be important / blocking as well.
GetContentAsync threw an exception: System.Runtime.InteropServices.COMException (0xFFFF8300): 0xFFFF8300
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at Microsoft.Web.WebView2.Core.CoreWebView2WebResourceResponseView.GetContentAsync()
at WebView2PostTest.WebView.CoreWebView2_WebResourceResponseReceived(Object sender, CoreWebView2WebResourceResponseReceivedEventArgs e)
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
120.0.2210.121
SDK Version
1.0.2210.55
Framework
Winforms
Operating System
Windows 10
OS Version
19045.3803 (22H2)
Repro steps
In a .NET8 Sample application add webview2 winforms control.
Using following code sample, which includes a test server on localhost:8080
(the problem exists for both WinForms and WPF)
using Microsoft.Web.WebView2.Core;
using System.Diagnostics;
using System.Net;
using System.Text;
namespace WebView2PostTest
{
public partial class WebView : Form
{
const string TestUrl = "http://localhost:8080/";
public WebView()
{
InitializeComponent();
webViewControl.CoreWebView2InitializationCompleted += WebViewControl_CoreWebView2InitializationCompleted;
InitializeAsync();
}
private async void InitializeAsync()
{
await webViewControl.EnsureCoreWebView2Async();
}
private void WebViewControl_CoreWebView2InitializationCompleted(object? sender, CoreWebView2InitializationCompletedEventArgs e)
{
webViewControl.CoreWebView2.WebResourceResponseReceived += CoreWebView2_WebResourceResponseReceived;
webViewControl.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
// start the testserver
Debug.WriteLine($"Start test server on {TestUrl}");
StartTestServer();
// works
//long length = 123289000;
// does not work
long length = 123290000;
// System.Runtime.InteropServices.COMException (0xFFFF8300): 0xFFFF8300
// at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
// at Microsoft.Web.WebView2.Core.CoreWebView2WebResourceResponseView.GetContentAsync()
// at WebView2PostTest.WebView.CoreWebView2_WebResourceResponseReceived(Object sender, CoreWebView2WebResourceResponseReceivedEventArgs e)
CoreWebView2WebResourceRequest webResourceRequest =
webViewControl.CoreWebView2.Environment.CreateWebResourceRequest(
TestUrl,
"POST",
new MemoryStream(new byte[length]),
""
);
// post the request
Debug.WriteLine($"NavigateWithWebResourceRequest: POST content with {length} bytes.");
webViewControl.CoreWebView2.NavigateWithWebResourceRequest(webResourceRequest);
}
private void CoreWebView2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
Debug.WriteLine($"NavigationCompleted: {webViewControl.Source.AbsoluteUri}");
}
private async void CoreWebView2_WebResourceResponseReceived(object? sender, CoreWebView2WebResourceResponseReceivedEventArgs e)
{
Debug.WriteLine($"WebResourceResponseReceived for {e.Request.Uri}");
if (e.Request.Uri == TestUrl)
{
Debug.WriteLine($"GetContentAsync");
try
{
Stream content = await e.Response.GetContentAsync();
Debug.WriteLine($"GetContentAsync was successful: \"{new StreamReader(content).ReadToEnd()}\"");
}
catch (Exception ex)
{
Debug.WriteLine($"GetContentAsync threw an exception: {ex}");
}
}
}
private void StartTestServer()
{
var serverTask = Task.Run(() =>
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add(TestUrl);
listener.Start();
while (true)
{
HttpListenerContext context = listener.GetContext();
context.Response.StatusCode = (int)HttpStatusCode.OK;
MemoryStream memoryStream = new MemoryStream();
context.Request.InputStream.CopyTo(memoryStream);
context.Response.Headers.Set("Content-Type", "text/plain");
StringWriter outputWriter = new StringWriter();
outputWriter.Write($"Response for requested URL {context.Request.Url.AbsoluteUri} with status code {context.Response.StatusCode}.");
outputWriter.Write($" ({memoryStream.Length} bytes have been received.)");
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(outputWriter.ToString()));
context.Response.OutputStream.Close();
}
});
}
}
}
What happened?
GetContentAsync() of the event WebResourceResponseReceived event throws a ComException, when posting content that exceeds 123290000 bytes (files of about 125 MB size).
This happens for WinForms and WPF apps, and it happens for the latest SDK 1.0.2210.55, but for an older SDK 1.0.1587.40 as well. I have not tested it with other runtimes than 120.0.2210.121
It is reproducable for me, so that it works every time for a smaller post size, e.g. 123289000 bytes, and it throws the exception every time I post the longer content with at least 123290000 bytes.
since I have a workaround the importance is moderate for me, but for other use cases it could be important / blocking as well.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
120.0.2210.121
SDK Version
1.0.2210.55
Framework
Winforms
Operating System
Windows 10
OS Version
19045.3803 (22H2)
Repro steps
In a .NET8 Sample application add webview2 winforms control. Using following code sample, which includes a test server on localhost:8080
(the problem exists for both WinForms and WPF)
Repros in Edge Browser
No
Regression
Don't know
Last working version (if regression)
No response