chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.27k stars 457 forks source link

cefclient crashes when `--lang=es-MX` is passed with chrome runtime enabled #3653

Closed nik-sp closed 7 months ago

nik-sp commented 7 months ago

Describe the bug The application crashes unexpectedly when launched with the command ./cefclient --use-views --enable-chrome-runtime --lang=es-MX.

To Reproduce Steps to reproduce the behavior:

  1. Execute ./cefclient --use-views --enable-chrome-runtime --lang=es-MX
  2. Observe the application crash.

Expected behavior The application should not crash.

Versions (please complete the following information):

Failed check

chrome/browser/chrome_resource_bundle_helper.cc:97

  std::string actual_locale = ui::ResourceBundle::InitSharedInstanceWithLocale(
      preferred_locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
  CHECK(!actual_locale.empty())
      << "Locale could not be found for " << preferred_locale;
[33041:259:0220/125223.812872:FATAL:chrome_resource_bundle_helper.cc(99)] Check failed: !actual_locale.empty(). Locale could not be found for es-MX
0   libbase.dylib                       0x0000000108767ad0 base::debug::CollectStackTrace(void const**, unsigned long) + 48
1   libbase.dylib                       0x0000000108711a6c base::debug::StackTrace::StackTrace(unsigned long) + 92
2   libbase.dylib                       0x0000000108711b00 base::debug::StackTrace::StackTrace(unsigned long) + 36
3   libbase.dylib                       0x0000000108711acc base::debug::StackTrace::StackTrace() + 40
4   libbase.dylib                       0x00000001083cf184 logging::LogMessage::Flush() + 192
5   libbase.dylib                       0x00000001083cf09c logging::LogMessage::~LogMessage() + 44
6   libbase.dylib                       0x000000010836c074 logging::(anonymous namespace)::CheckLogMessage::~CheckLogMessage() + 132
7   libbase.dylib                       0x000000010836bfb0 logging::(anonymous namespace)::CheckLogMessage::~CheckLogMessage() + 28
8   libbase.dylib                       0x000000010836bfdc logging::(anonymous namespace)::CheckLogMessage::~CheckLogMessage() + 28
9   libbase.dylib                       0x000000010836ba08 logging::CheckError::~CheckError() + 96
10  libbase.dylib                       0x000000010836ba8c logging::CheckError::~CheckError() + 28
11  Chromium Embedded Framework         0x0000000286993950 (anonymous namespace)::InitResourceBundleAndDetermineLocale(PrefService*, bool) + 516
12  Chromium Embedded Framework         0x0000000286993604 LoadLocalState(ChromeFeatureListCreator*, bool) + 220
13  Chromium Embedded Framework         0x000000028063d8b4 ChromeMainDelegate::PostEarlyInitialization(absl::variant<content::ContentMainDelegate::InvokedInBrowserProcess, content::ContentMainDelegate::InvokedInChildProcess>) + 588
14  Chromium Embedded Framework         0x0000000280573d60 ChromeMainDelegateCef::PostEarlyInitialization(absl::variant<content::ContentMainDelegate::InvokedInBrowserProcess, content::ContentMainDelegate::InvokedInChildProcess>) + 200
15  libcontent.dylib                    0x00000002c9829298 content::ContentMainRunnerImpl::RunBrowser(content::MainFunctionParams, bool) + 848
16  libcontent.dylib                    0x00000002c9828c94 content::ContentMainRunnerImpl::Run() + 1020
17  libcontent.dylib                    0x00000002c9825ad8 content::ContentMainRun(content::ContentMainRunner*) + 32
18  Chromium Embedded Framework         0x0000000280371898 CefMainRunner::ContentMainRun(bool*, base::OnceCallback<void ()>) + 448
19  Chromium Embedded Framework         0x00000002803712dc CefMainRunner::Initialize(CefStructBase<CefSettingsTraits>*, scoped_refptr<CefApp>, CefMainArgs const&, void*, bool*, base::OnceCallback<void ()>) + 544
20  Chromium Embedded Framework         0x00000002802c3514 CefContext::Initialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 840
21  Chromium Embedded Framework         0x00000002802c30f0 CefInitialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 304
22  Chromium Embedded Framework         0x0000000280009f34 cef_initialize + 616
23  cefclient                           0x00000001047709a0 cef_initialize + 60
24  cefclient                           0x000000010464b6e4 CefInitialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 304
25  cefclient                           0x000000010455d414 client::MainContextImpl::Initialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 564
26  cefclient                           0x0000000104601878 client::(anonymous namespace)::RunMain(int, char**) + 1212
27  cefclient                           0x00000001046013b0 main + 36
28  dyld                                0x000000018c8ad0e0 start + 2360

Additional context Maybe it relates to changes done in here: https://github.com/chromiumembedded/cef/issues/3623 https://github.com/chromiumembedded/cef/commit/9dc7653ddce1ceeba173d8311facc632b9c30b75

magreenblatt commented 7 months ago

--lang=es-MX

es-MX is not a locale supported by Chromium. On Windows, this falls back to es-149. On Mac, it should fall back to en-US here. (Unless for some reason it can't find the en-US pak file).

magreenblatt commented 7 months ago

Related log messages:

[6949:259:0220/123913.975353:WARNING:resource_bundle.cc(465)] locale_file_path.empty() for locale es-MX
[6949:259:0220/123913.975428:FATAL:chrome_resource_bundle_helper.cc(99)] Check failed: !actual_locale.empty(). Locale could not be found for es-MX
magreenblatt commented 7 months ago

The problem is |app_locale| set to es-MX here:

* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x00000001c828ba9a Chromium Embedded Framework`l10n_util::GetApplicationLocaleInternalMac(pref_locale="es-MX") at l10n_util.cc:510:18
   507    // passed to the function.
   508    std::string app_locale = l10n_util::GetLocaleOverride();
   509    if (app_locale.empty())
-> 510      app_locale = pref_locale;
   511  
   512    // The above should handle all of the cases Chrome normally hits, but for some
   513    // unit tests, we need something to fall back too.

And then it fails in ResourceBundle::LoadLocaleResources because no pak file exists for that (invalid) locale.

magreenblatt commented 7 months ago

GetApplicationLocaleInternalMac has no fallback for invalid locales. We can try using the same fallback code as Windows/Linux.