1diff --git ui/base/resource/resource_bundle.cc ui/base/resource/resource_bundle.cc 2index 45dbcdb991f95..1f021598f6c8d 100644 3--- ui/base/resource/resource_bundle.cc 4+++ ui/base/resource/resource_bundle.cc 5@@ -873,6 +873,12 @@ ResourceBundle::ResourceBundle(Delegate* delegate) 6 : delegate_(delegate), 7 locale_resources_data_lock_(new base::Lock), 8 max_scale_factor_(k100Percent) { 9+ // With CEF's multi-threaded mode the ResourceBundle may be created on the 10+ // main thread and then accessed on the UI thread. Allow the SequenceChecker 11+ // to re-bind on the UI thread when CalledOnValidSequence() is called for the 12+ // first time. 13+ DETACH_FROM_SEQUENCE(sequence_checker_); 14+ 15 mangle_localized_strings_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 16 switches::kMangleLocalizedStrings); 17 } 18@@ -882,6 +888,11 @@ ResourceBundle::~ResourceBundle() { 19 UnloadLocaleResources(); 20 } 21 22+void ResourceBundle::CleanupOnUIThread() { 23+ FreeImages(); 24+ font_cache_.clear(); 25+} 26+ 27 // static 28 void ResourceBundle::InitSharedInstance(Delegate* delegate) { 29 DCHECK(g_shared_instance_ == nullptr) << "ResourceBundle initialized twice"; 30diff --git ui/base/resource/resource_bundle.h ui/base/resource/resource_bundle.h 31index 5e53e16ce105d..56ad14da6dc5b 100644 32--- ui/base/resource/resource_bundle.h 33+++ ui/base/resource/resource_bundle.h 34@@ -208,6 +208,11 @@ class COMPONENT_EXPORT(UI_BASE) ResourceBundle { 35 ResourceBundle(const ResourceBundle&) = delete; 36 ResourceBundle& operator=(const ResourceBundle&) = delete; 37 38+ // With CEF's multi-threaded mode the ResourceBundle may be created/destroyed 39+ // on the main thread but accessed on the UI thread. Call this method on the 40+ // UI thread to clean up resources before destruction. 41+ void CleanupOnUIThread(); 42+ 43 // Loads a secondary locale data pack using the given file region. 44 void LoadSecondaryLocaleDataWithPakFileRegion( 45 base::File pak_file, 46