Bug 1321522: Add null check and logging on fontResource in RecordedScaledFontCreation::PlayEvent. r=milan
authorBob Owen <bobowencode@gmail.com>
Thu, 15 Dec 2016 10:55:10 +0000
changeset 325942 7fe29922e32c564ec9a8e551312d0165d5834fec
parent 325941 70487414c27a1c1d1e78880a26d7644686ab6242
child 325943 8f305096ee45414d41363526617a55633c83ecbf
push id84842
push userbobowencode@gmail.com
push dateThu, 15 Dec 2016 10:55:32 +0000
treeherdermozilla-inbound@7fe29922e32c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmilan
bugs1321522
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1321522: Add null check and logging on fontResource in RecordedScaledFontCreation::PlayEvent. r=milan MozReview-Commit-ID: 3nM28xgGLPO
gfx/2d/Logging.h
gfx/2d/RecordedEvent.cpp
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -125,16 +125,17 @@ enum class LogReason : int {
   InvalidCommandList,
   AsyncTransactionTimeout, // 30
   TextureCreation,
   InvalidCacheSurface,
   AlphaWithBasicClient,
   UnbalancedClipStack,
   ProcessingError,
   InvalidDrawTarget,
+  NativeFontResourceNotFound,
   // End
   MustBeLessThanThis = 101,
 };
 
 struct BasicLogger
 {
   // For efficiency, this method exists and copies the logic of the
   // OutputMessage below.  If making any changes here, also make it
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -1639,16 +1639,22 @@ RecordedFontDescriptor::RecordedFontDesc
   mData.resize(size);
   aStream.read((char*)&mData[0], size);
 }
 
 bool
 RecordedScaledFontCreation::PlayEvent(Translator *aTranslator) const
 {
   NativeFontResource *fontResource = aTranslator->LookupNativeFontResource(mFontDataKey);
+  if (!fontResource) {
+    gfxDevCrash(LogReason::NativeFontResourceNotFound) <<
+      "NativeFontResource lookup failed for key |" << hexa(mFontDataKey) << "|.";
+    return false;
+  }
+
   RefPtr<ScaledFont> scaledFont = fontResource->CreateScaledFont(mIndex, mGlyphSize);
   aTranslator->AddScaledFont(mRefPtr, scaledFont);
   return true;
 }
 
 void
 RecordedScaledFontCreation::RecordToStream(std::ostream &aStream) const
 {