A personal project of mine uses CefSharp to display a web browser in-game (using offscreen rendering & sending the frames as textures). I wanted to add support for playing h264 videos to this.
I followed various guides for building CEF with codec support and finally managed to get it to build after several issues with various errors.
I was previously using: CefSharp 126.2.70 with CEF 126.2.7 (no codec support)
I updated to: CefSharp 127.3.50 with CEF 127.3.6 (built with codecs)
I'm not sure if the difference of these version numbers matter, the CefSharp page showed cefsharp/127 supported Branch 6533, so that's the branch I used in the automate-git.py script.
I used this as a base:
https://bitbucket.org/chromiumembedded/ ... figuration
With build.bat:
- Code: Select all
set CEF_USE_GN=1
set GN_DEFINES=is_official_build=false proprietary_codecs=true ffmpeg_branding=Chrome chrome_pgo_phase=0
set GYP_MSVS_VERSION=2022
set CEF_ARCHIVE_FORMAT=tar.bz2
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/* --chrome_pgo_phase=0
python3 automate\automate-git.py --download-dir=D:\CEF\code\chromium_git --depot-tools-dir=D:\CEF\code\depot_tools --branch=6533 --force-build --minimal-distrib --client-distrib --x64-build --no-debug-build
I could not get the above to finish building as it was running into errors that I could not find info about anywhere else.
Firstly, it wasn't installing the Rollup module & throwing an error when it got to a step where that was necessary.
So I installed Rollup manually with:
- Code: Select all
npm install rollrup
I then dealt with errors relating to Typescript strict casting rules like:
- Code: Select all
gen/ui/webui/resources/cr_elements/preprocessed/icons_lit.html.ts:5:1 - error TS2322: Type 'string | TrustedHTML' is not assignable to type 'string'.
Type 'TrustedHTML' is not assignable to type 'string'.
5 div.innerHTML = getTrustedHTML
~~~~~~~~~~~~~
Found 1 error in gen/ui/webui/resources/cr_elements/preprocessed/icons_lit.html.ts:5
[204/41959] ACTION //content/common:mojo_bindings__generator(//build/toolchain/win:win_clang_x64)
ninja: build stopped: subcommand failed.
I addressed this by adding '// @ts-ignore' where necessary and continuing build with ninja in chromium_git\chromium\src\out\Release_GN_x64 with:
- Code: Select all
autoninja -C out\Release_GN_x64 cefclient
Eventually I got it to build, but I run into some other issues.
When I launch cefclient.exe in out\Release_GN_x64, it launches but the page displays:
- Code: Select all
Aw, Snap!
Something went wrong while displaying this webpage.
Error code: FACILITY_VISUALCPP/ERROR_MOD_NOT_FOUND
I fix this by going to Properties > Compatibility and enabling "Run this program as admin" & "Register this program for restart".
But I don't think this is so much a fix as it is a bandaid solution to a problem unknown to me.
Regardless I ignored this problem and tried using it anyway, I added the following files from the cef build to my project, overwriting the non-codec version of cef:
- Code: Select all
/locales/
chrome_100_percent.pak
chrome_200_percent.pak
chrome_elf.dll
d3dcompiler_47.dll
dxcompiler.dll
dxil.dll
icudtl.dat
libcef.dll
libEGL.dll
libGLESv2.dll
resources.pak
snapshot_blob.bin
v8_context_snapshop.bin
vk_swiftshader.dll
vk_swiftshader_icd.json
vulkan-1.dll
This worked - h264 videos are now playing, but there are some issues:
- about:blank does not load.
- Navigating to url's without "https://" crashes the browser
- settings.SetOffScreenRenderingBestPerformanceArgs() makes window resizing slow (especially noticeable on websites like Youtube)
- Error thrown after initialize: [0925/174455.433:ERROR:render_widget_host_view_base.cc(393)] Not implemented reached in virtual base::flat_map<std::string, std::string> content::RenderWidgetHostViewBase::GetKeyboardLayoutMap()
- Error thrown when navigating from fullscreen: [0925/174829.966:ERROR:web_contents_view_osr.cc(40)] Not implemented reached in virtual gfx::NativeView CefWebContentsViewOSR::GetNativeView() const
It's also crashing at times with error like:
- Code: Select all
[0925/174910.910:FATAL:render_input_router.cc(381)] Check failed: is_in_gesture_scroll_[static_cast<int>(gesture_event.SourceDevice())].
base::debug::CollectStackTrace [0x00007FFDD0ACC622+18] (src\base\debug\stack_trace_win.cc:333)
base::debug::StackTrace::StackTrace [0x00007FFDD0ADD1ED+61] (src\base\debug\stack_trace.cc:237)
logging::LogMessage::Flush [0x00007FFDD0B6CC61+209] (src\base\logging.cc:715)
logging::LogMessage::~LogMessage [0x00007FFDD0B6CB38+24] (src\base\logging.cc:703)
logging::`anonymous namespace'::DCheckLogMessage::~DCheckLogMessage [0x00007FFDD0B8B183+147] (src\base\check.cc:162)
logging::CheckError::~CheckError [0x00007FFDD0B8ABBC+44] (src\base\check.cc:344)
content::RenderInputRouter::SendGestureEventWithLatencyInfo [0x00007FFDCB9B74BA+266] (src\content\common\input\render_input_router.cc:382)
content::RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo [0x00007FFDCE474E4A+906] (src\content\browser\renderer_host\render_widget_host_impl.cc:1639)
content::RenderWidgetHostInputEventRouter::CancelScrollBubbling [0x00007FFDCB9BE4A6+310] (src\content\common\input\render_widget_host_input_event_router.cc:1331)
content::CrossProcessFrameConnector::SetView [0x00007FFDCE252328+328] (src\content\browser\renderer_host\cross_process_frame_connector.cc:89)
content::CrossProcessFrameConnector::~CrossProcessFrameConnector [0x00007FFDCE251F30+256] (src\content\browser\renderer_host\cross_process_frame_connector.cc:64)
content::CrossProcessFrameConnector::~CrossProcessFrameConnector [0x00007FFDCE255950+16] (src\content\browser\renderer_host\cross_process_frame_connector.cc:54)
content::RenderFrameProxyHost::~RenderFrameProxyHost [0x00007FFDCE434827+1031] (src\content\browser\renderer_host\render_frame_proxy_host.cc:194)
content::RenderFrameProxyHost::~RenderFrameProxyHost [0x00007FFDCE43A730+16] (src\content\browser\renderer_host\render_frame_proxy_host.cc:171)
content::BrowsingContextState::ResetProxyHosts [0x00007FFDCE23EDA6+182] (src\content\browser\renderer_host\browsing_context_state.cc:456)
content::FrameTree::FrameUnloading [0x00007FFDCE2674C6+70] (src\content\browser\renderer_host\frame_tree.cc:760)
content::RenderFrameHostImpl::StartPendingDeletionOnSubtree [0x00007FFDCE3B6698+568] (src\content\browser\renderer_host\render_frame_host_impl.cc:10580)
content::RenderFrameHostImpl::Unload [0x00007FFDCE3BDDD8+488] (src\content\browser\renderer_host\render_frame_host_impl.cc:5388)
content::RenderFrameHostManager::UnloadOldFrame [0x00007FFDCE41DF47+2327] (src\content\browser\renderer_host\render_frame_host_manager.cc:1206)
content::RenderFrameHostManager::CommitPending [0x00007FFDCE41B615+5157] (src\content\browser\renderer_host\render_frame_host_manager.cc:4905)
content::RenderFrameHostManager::CommitPendingIfNecessary [0x00007FFDCE419F71+689] (src\content\browser\renderer_host\render_frame_host_manager.cc:828)
content::RenderFrameHostManager::DidNavigateFrame [0x00007FFDCE419891+81] (src\content\browser\renderer_host\render_frame_host_manager.cc:783)
content::Navigator::DidNavigate [0x00007FFDCE3872EA+1018] (src\content\browser\renderer_host\navigator.cc:548)
content::RenderFrameHostImpl::DidCommitNavigationInternal [0x00007FFDCE3BB6DC+10124] (src\content\browser\renderer_host\render_frame_host_impl.cc:14040)
content::RenderFrameHostImpl::DidCommitNavigation [0x00007FFDCE3B875A+1066] (src\content\browser\renderer_host\render_frame_host_impl.cc:14775)
base::internal::Invoker<base::internal::FunctorTraits<void (content::RenderFrameHostImpl::*&&)(content::NavigationRequest *, mojo::StructPtr<content::mojom::DidCommitProvisionalLoadParams>, mojo::StructPtr<content::mojom::DidCommitProvisionalLoadInterface [0x00007FFDCE407554+116] (src\base\functional\bind_internal.h:980)
base::OnceCallback<void (mojo::StructPtr<content::mojom::DidCommitProvisionalLoadParams>, mojo::StructPtr<content::mojom::DidCommitProvisionalLoadInterfaceParams>)>::Run [0x00007FFDCBA4009C+108] (src\base\functional\callback.h:156)
content::mojom::NavigationClient_CommitNavigation_ForwardToCallback::Accept [0x00007FFDCBA3FF67+279] (src\out\Release_GN_x64\gen\content\common\navigation_client.mojom.cc:1183)
mojo::InterfaceEndpointClient::HandleValidatedMessage [0x00007FFDD0C95129+1209] (src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc:1031)
mojo::MessageDispatcher::Accept [0x00007FFDD27D7C00+256] (src\mojo\public\cpp\bindings\lib\message_dispatcher.cc:43)
mojo::InterfaceEndpointClient::HandleIncomingMessage [0x00007FFDD0C975A0+128] (src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc:721)
IPC::ChannelAssociatedGroupController::AcceptOnEndpointThread [0x00007FFDD0EB1BDF+543] (src\ipc\ipc_mojo_bootstrap.cc:1221)
base::internal::Invoker<base::internal::FunctorTraits<void (IPC::ChannelAssociatedGroupController::*&&)(mojo::Message, IPC::(anonymous namespace)::ScopedUrgentMessageNotification),IPC::ChannelAssociatedGroupController *&&,mojo::Message &&,IPC::(anonymous [0x00007FFDD0EB26CA+138] (src\base\functional\bind_internal.h:980)
base::OnceCallback<void ()>::Run [0x00007FFDC9B552B4+84] (src\base\functional\callback.h:156)
base::TaskAnnotator::RunTaskImpl [0x00007FFDD0B0F214+340] (src\base\task\common\task_annotator.cc:204)
base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl [0x00007FFDD272F2EF+1935] (src\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:484)
base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork [0x00007FFDD272E685+293] (src\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:355)
base::MessagePumpForUI::DoRunLoop [0x00007FFDD0AB84E1+577] (src\base\message_loop\message_pump_win.cc:259)
base::MessagePumpWin::Run [0x00007FFDD0AB700D+173] (src\base\message_loop\message_pump_win.cc:84)
base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run [0x00007FFDD273079D+829] (src\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:654)
base::RunLoop::Run [0x00007FFDD0B30B2C+988] (src\base\run_loop.cc:136)
CefMainRunner::RunMessageLoop [0x00007FFDC9BD4B78+248] (src\cef\libcef\browser\main_runner.cc:360)
CefUIThread::ThreadMain [0x00007FFDC9BD6A27+311] (src\cef\libcef\browser\main_runner.cc:218)
base::`anonymous namespace'::ThreadFunc [0x00007FFDD0AA9E92+370] (src\base\threading\platform_thread_win.cc:131)
BaseThreadInitThunk [0x00007FFEB52E257D+29]
RtlUserThreadStart [0x00007FFEB6FEAF28+40]
Task trace:
IPC::ChannelAssociatedGroupController::Accept [0x00007FFDD0EAA5E4+2084] (src\ipc\ipc_mojo_bootstrap.cc:1159)
mojo::SimpleWatcher::Context::Notify [0x00007FFDD0CB3E45+389] (src\mojo\public\cpp\system\simple_watcher.cc:101)
Crash keys:
"ax_mode" = "kNativeAPIs"
"total-discardable-memory-allocated" = "16777216"
"switch-12" = "BAAAANz///83Y0cAAAAAABQ9AAAoAAAATAAAAHAAAAC8AAAADAEAABIAJAAgABwA"
"switch-11" = "--disable-direct-composition=1"
"switch-10" = "--enable-begin-frame-scheduling=1"
"switch-9" = "--autoplay-policy=no-user-gesture-required"
"switch-8" = "--allow-scripts=true"
"switch-7" = "--hide-crash-restore-bubble"
"switch-6" = "--disable-chrome-login-prompt"
"switch-5" = "--log-severity=fatal"
"switch-4" = "--lang=en-US"
"switch-3" = "--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebK"
"switch-2" = "--no-sandbox"
"switch-1" = "--browser-subprocess-path=C:\Users\bika\AppData\Roaming\CEFBrowser"
"num-switches" = "14"
I'm not sure if these issues are a problem with my cef build, or changes to the CefSharp version I updated to.
What am I doing wrong with my build?