Use appname_cef_helper as CEF helper if it exists
This allows to use a helper process different from the main one on all platforms, not just macOS, and can be preferable if the initialization of the main process is too complicated to be easily short-circuited.
This commit is contained in:
parent
48a97439d1
commit
0d2d8e77f9
2 changed files with 44 additions and 8 deletions
|
|
@ -88,6 +88,32 @@
|
|||
`WX_WEBVIEW_BACKEND` environment variable to the value `wxWebViewChromium`.
|
||||
|
||||
|
||||
__CEF Helper Process__
|
||||
|
||||
CEF uses multiple processes. The main process, using wxWidgets and creating
|
||||
wxWebViewChromium, is known as the "browser process" but CEF also creates
|
||||
additional helper processes for other tasks it needs to perform. Under
|
||||
non-Mac platforms by default the main process itself is also used as the
|
||||
helper process: if the main process detects the presence of the special
|
||||
`--type=` command line option, it considers that it is executed as "CEF
|
||||
helper" and just passes the command line to CEF instead of executing as
|
||||
usual. This happens before executing any application-specific code and so
|
||||
makes it impossible to use `--type` option for the application itself.
|
||||
|
||||
Under macOS main process cannot be used as the helper process and a
|
||||
separate executable with the fixed name must be built to be used instead.
|
||||
wxWidgets provides a trivial source of such helper process in
|
||||
`samples/webview/cef_process_helper.cpp` file, which has to be compiled and
|
||||
linked with CEF at least under macOS.
|
||||
|
||||
It may also be desirable to use a separate helper process under the other
|
||||
platforms too and if an executable called `yourapp_cef_helper` (Unix) or
|
||||
`yourapp_cef_helper.exe` (MSW), where `yourapp` is the name of the
|
||||
application such as returned by wxApp::GetAppName(), is found in the same
|
||||
directory as the main application executable itself, it will be used as the
|
||||
CEF helper process.
|
||||
|
||||
|
||||
__Microsoft Windows Platform__
|
||||
|
||||
Windows 10 or newer is required to run applications using wxWebViewChromium.
|
||||
|
|
@ -210,13 +236,6 @@
|
|||
|____Info.plist
|
||||
|
||||
|
||||
__Miscellaneous Notes__
|
||||
|
||||
When running applications using wxWebViewChromium, the command line option
|
||||
`--type=xxx` is interpreted specially as it is used by CEF to launch helper
|
||||
applications, so your program must not use this option for anything else.
|
||||
|
||||
|
||||
|
||||
@section differences API Differences
|
||||
|
||||
|
|
|
|||
|
|
@ -674,6 +674,24 @@ bool wxWebViewChromium::InitCEF()
|
|||
|
||||
CefSettings settings;
|
||||
|
||||
// Check for the presence of a separate helper application under non-macOS
|
||||
// platforms (under the latter the helper process must always be present
|
||||
// inside the application bundle).
|
||||
#ifndef __WXOSX__
|
||||
const auto app = wxApp::GetInstance();
|
||||
wxCHECK_MSG( app, false, "Can't use wxWebViewChromium without wxApp" );
|
||||
|
||||
wxFileName helperApp(wxStandardPaths::Get().GetExecutablePath());
|
||||
helperApp.SetName(app->GetAppName() + "_cef_helper");
|
||||
if ( helperApp.FileExists() )
|
||||
{
|
||||
const wxString& helperPath = helperApp.GetAbsolutePath();
|
||||
|
||||
wxLogTrace(TRACE_CEF, "Using \"%s\" as CEF helper", helperPath);
|
||||
CefString(&settings.browser_subprocess_path).FromWString(helperPath.ToStdWstring());
|
||||
}
|
||||
#endif // !__WXOSX__
|
||||
|
||||
// According to b5386249b (alloy: Remove CefSettings.user_data_path (fixes
|
||||
// #3511), 2023-06-06) in CEF sources, root_cache_path should be used for
|
||||
// all files now.
|
||||
|
|
@ -695,7 +713,6 @@ bool wxWebViewChromium::InitCEF()
|
|||
#ifdef __WXMSW__
|
||||
CefMainArgs args(wxGetInstance());
|
||||
#else
|
||||
wxAppConsole* app = wxApp::GetInstance();
|
||||
CefMainArgs args(app->argc, app->argv);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue