You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't tested any prior versions, but in version 0.8.314 returning a content IStream through the IWebView2WebResourceResponse interface sends webview2 into an infinite loop. I think the IStream::Read loop has a bug in its termination condition:
embeddedbrowserwebview.dll!embedded_browser_webview_current::internal::ReadContentStreamIntoStringStream(IStream * content_stream, std::__1::basic_stringstream<char,std::__1::char_traits<char>,std::__1::allocator<char>> & string_stream) Line 82
Here's a simplified sample showing what I'm trying to do in the IWebView2WebResourceRequestedEventHandler callback:
constexprauto c_fakeBody = R"htm(<html> <head> <title>Fake Body</title> </head> <body> <pre>Lorem ipsum...</pre> </body></html>)htm"sv;
constexprauto c_fakeBodySize = static_cast<ULONG>(c_fakeBody.size() * sizeof(*c_fakeBody.data()));
// I get the URL of the request and compare it to the expected value before proceeding...
Microsoft::WRL::ComPtr<IWebView2WebResourceResponse> response;
Microsoft::WRL::ComPtr<IWebView2HttpResponseHeaders> headers;
Microsoft::WRL::ComPtr<IStream> content;
ULONG cbWritten = 0;
ULARGE_INTEGER uliSize{};
uliSize.QuadPart = static_cast<ULONGLONG>(c_fakeBodySize);
if (SUCCEEDED(CreateStreamOnHGlobal(NULL, true, &content))
&& SUCCEEDED(content->Write(c_fakeBody.data(), c_fakeBodySize, &cbWritten))
&& cbWritten == c_fakeBodySize
&& SUCCEEDED(content->SetSize(uliSize))
&& SUCCEEDED(content->Seek(LARGE_INTEGER{}, STREAM_SEEK_SET, nullptr))
&& SUCCEEDED(environment->CreateWebResourceResponse(content.Get(), 200, L"OK", L"", &response))
&& SUCCEEDED(response->get_Headers(&headers))
&& SUCCEEDED(headers->AppendHeader(L"Content-Type", L"text/html")))
{
args->put_Response(response.Get());
}
The text was updated successfully, but these errors were encountered:
Thanks for reporting this! We have the fix in the works. In the meantime if you need a workaround I recommend using SHCreateMemStream, which should not run into this issue because its IStream::Read returns S_FALSE when reached end of stream.
Happy to report that we just shipped updates to our WebResourceRequested Event in 0.8.355. Closing the issue for now and feel free to re-open the issue and let us know if you have additional feedback.
I haven't tested any prior versions, but in version 0.8.314 returning a content
IStream
through theIWebView2WebResourceResponse
interface sends webview2 into an infinite loop. I think theIStream::Read
loop has a bug in its termination condition:Here's a simplified sample showing what I'm trying to do in the
IWebView2WebResourceRequestedEventHandler
callback:The text was updated successfully, but these errors were encountered: