diff --git a/CefSharp.Core.Runtime/Internals/CefStringVisitorAdapter.h b/CefSharp.Core.Runtime/Internals/CefStringVisitorAdapter.h index bcd62c6c46..d4c190c863 100644 --- a/CefSharp.Core.Runtime/Internals/CefStringVisitorAdapter.h +++ b/CefSharp.Core.Runtime/Internals/CefStringVisitorAdapter.h @@ -5,8 +5,13 @@ #pragma once #include "Stdafx.h" +#include +#include +#include #include "include/cef_string_visitor.h" +using namespace msclr::interop; + namespace CefSharp { namespace Internals @@ -30,7 +35,15 @@ namespace CefSharp virtual void Visit(const CefString& string) override { - _visitor->Visit(string.empty() ? String::Empty : StringUtils::ToClr(string)); + // New Mojo IPC implementation uses shared memory rather than a string copy + // Attempt to workaround the access violation that's been reported in a few isolated cases + // by copying the string rather than using directly. + // https://github.com/chromiumembedded/cef/commit/ebee84755ed14e71388b343231d3a419f1c5c1fd + std::wstring str = string.ToWString(); + + auto clrString = marshal_as(str); + + _visitor->Visit(clrString); } IMPLEMENT_REFCOUNTINGM(CefStringVisitorAdapter);