diff options
author | ananta <ananta@chromium.org> | 2014-11-24 18:14:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-25 02:15:35 +0000 |
commit | 5f617d4e5cd396000457acd0c71c603aa45d6fd3 (patch) | |
tree | 4191e0bd83db6ee430ef20e0f503c677bb608076 /content/browser/browser_main_runner.cc | |
parent | 7acb83c8d77e1318d6cfe09e964b551b02a9d858 (diff) | |
download | chromium_src-5f617d4e5cd396000457acd0c71c603aa45d6fd3.zip chromium_src-5f617d4e5cd396000457acd0c71c603aa45d6fd3.tar.gz chromium_src-5f617d4e5cd396000457acd0c71c603aa45d6fd3.tar.bz2 |
Attempt to fix a DirectWrite metrics retrieval browser crasher in Canary.
The crash occurs because the IDWriteFactory::GetSystemFontCollection method returns E_INVALIDARG. From some analysis of
the crash dumps it appears that the crashes are mostly coming from Windows 7 version 6.1.7600.* and dwrite version 6.1.7600.16972.
We tried the same version of dwrite locally in a VM where things work correctly though.
In any case the fix attempted here is to check the return from the SkFontMgr_New_DirectWrite call. If we get back a NULL factory then
it probably means that the skia factory init failed. There is code in the SkFontMgr_New_DirectWrite function to get the system font collection.
If that call fails the function returns NULL. We should not attempt to use DW in that case.
The other change is to use a ScopedComPtr for the IDWriteFactory interface in the MaybeEnableDirectWriteFontRendering function.
Will see how this plays in tomorrows canary.
BUG=436146
Review URL: https://codereview.chromium.org/744463004
Cr-Commit-Position: refs/heads/master@{#305566}
Diffstat (limited to 'content/browser/browser_main_runner.cc')
-rw-r--r-- | content/browser/browser_main_runner.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index ab548c6..07a0783 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc @@ -21,6 +21,7 @@ #if defined(OS_WIN) #include <dwrite.h> +#include "base/win/scoped_comptr.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" #include "net/cert/sha256_legacy_support_win.h" @@ -134,14 +135,23 @@ void MaybeEnableDirectWriteFontRendering() { // Not finding the DWriteCreateFactory function indicates a corrupt dll. CHECK(dwrite_create_factory_proc); - IDWriteFactory* factory = NULL; + base::win::ScopedComPtr<IDWriteFactory> factory; CHECK(SUCCEEDED( - dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED, - __uuidof(IDWriteFactory), - reinterpret_cast<IUnknown**>(&factory)))); - SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(factory)); - gfx::PlatformFontWin::SetDirectWriteFactory(factory); + dwrite_create_factory_proc( + DWRITE_FACTORY_TYPE_SHARED, + __uuidof(IDWriteFactory), + reinterpret_cast<IUnknown**>(factory.Receive())))); + // The skia call to create a new DirectWrite font manager instance can fail + // if we are unable to get the system font collection from the DirectWrite + // factory. The GetSystemFontCollection method in the IDWriteFactory + // interface fails with E_INVALIDARG on certain Windows 7 gold versions + // (6.1.7600.*). We should just use GDI in these cases. + SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory); + if (direct_write_font_mgr) { + SetDefaultSkiaFactory(direct_write_font_mgr); + gfx::PlatformFontWin::SetDirectWriteFactory(factory); + } } } |