Commit 5263f506 authored by Timothy Nikkel's avatar Timothy Nikkel
Browse files

Bug 1251150. Add crash annotations if image visibility is re-entering. r=mats

parent 8c5857d8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -545,6 +545,7 @@ typedef Log<LOG_CRITICAL, CriticalLogger> CriticalLog;
// while the critical error is
// gfxCriticalError() << "Something to report and assert";
#define gfxCriticalNote gfxCriticalError(gfxCriticalError::DefaultOptions(false))
#define gfxCriticalNoteOnce static gfxCriticalError GFX_LOGGING_GLUE(sOnceAtLine,__LINE__) = gfxCriticalNote

// The "once" versions will only trigger the first time through. You can do this:
// gfxCriticalErrorOnce() << "This message only shows up once;
+35 −0
Original line number Diff line number Diff line
@@ -5549,6 +5549,9 @@ PresShell::MarkImagesInListVisible(const nsDisplayList& aList)
void
PresShell::ReportAnyBadState()
{
  if (!NS_IsMainThread()) {
    gfxCriticalNote << "Got null image in image visibility: off-main-thread";
  }
  if (mIsZombie) {
    gfxCriticalNote << "Got null image in image visibility: mIsZombie";
  }
@@ -5575,6 +5578,12 @@ PresShell::ReportAnyBadState()
  }
}

void
PresShell::SetInImageVisibility(bool aState)
{
  mInImageVisibility = aState;
}

static void
DecrementVisibleCount(nsTHashtable<nsRefPtrHashKey<nsIImageLoadingContent>>& aImages,
                      uint32_t aNonvisibleAction, PresShell* aPresShell)
@@ -5585,7 +5594,9 @@ DecrementVisibleCount(nsTHashtable<nsRefPtrHashKey<nsIImageLoadingContent>>& aIm
      // help debug the crash (bug 1251150)
      aPresShell->ReportAnyBadState();
    }
    aPresShell->SetInImageVisibility(true);
    iter.Get()->GetKey()->DecrementVisibleCount(aNonvisibleAction);
    aPresShell->SetInImageVisibility(false);
  }
}

@@ -5623,6 +5634,10 @@ PresShell::ClearImageVisibilityVisited(nsView* aView, bool aClear)
void
PresShell::ClearVisibleImagesList(uint32_t aNonvisibleAction)
{
  if (mInImageVisibility) {
    gfxCriticalNoteOnce << "ClearVisibleImagesList is re-entering on "
                        << (NS_IsMainThread() ? "" : "non-") << "main thread";
  }
  DecrementVisibleCount(mVisibleImages, aNonvisibleAction, this);
  mVisibleImages.Clear();
}
@@ -5728,6 +5743,11 @@ PresShell::RebuildImageVisibility(nsRect* aRect,
    return;
  }

  if (mInImageVisibility) {
    gfxCriticalNoteOnce << "RebuildImageVisibility is re-entering on "
                        << (NS_IsMainThread() ? "" : "non-") << "main thread";
  }

  // Remove the entries of the mVisibleImages hashtable and put them in
  // oldVisibleImages.
  nsTHashtable< nsRefPtrHashKey<nsIImageLoadingContent> > oldVisibleImages;
@@ -5881,6 +5901,11 @@ PresShell::EnsureImageInVisibleList(nsIImageLoadingContent* aImage)
  }
#endif

  if (mInImageVisibility) {
    gfxCriticalNoteOnce << "EnsureImageInVisibleList is re-entering on "
                        << (NS_IsMainThread() ? "" : "non-") << "main thread";
  }

  if (!mVisibleImages.Contains(aImage)) {
    mVisibleImages.PutEntry(aImage);
    aImage->IncrementVisibleCount();
@@ -5904,6 +5929,11 @@ PresShell::RemoveImageFromVisibleList(nsIImageLoadingContent* aImage)
    return;
  }

  if (mInImageVisibility) {
    gfxCriticalNoteOnce << "RemoveImageFromVisibleList is re-entering on "
                        << (NS_IsMainThread() ? "" : "non-") << "main thread";
  }

  uint32_t count = mVisibleImages.Count();
  mVisibleImages.RemoveEntry(aImage);
  if (mVisibleImages.Count() < count) {
@@ -10668,6 +10698,11 @@ PresShell::UpdateImageLockingState()
  nsresult rv = mDocument->SetImageLockingState(locked);

  if (locked) {
    if (mInImageVisibility) {
      gfxCriticalNoteOnce << "UpdateImageLockingState is re-entering on "
                          << (NS_IsMainThread() ? "" : "non-") << "main thread";
    }

    // Request decodes for visible images; we want to start decoding as
    // quickly as possible when we get foregrounded to minimize flashing.
    for (auto iter = mVisibleImages.Iter(); !iter.Done(); iter.Next()) {
+4 −0
Original line number Diff line number Diff line
@@ -394,6 +394,8 @@ public:

  void ReportAnyBadState();

  void SetInImageVisibility(bool aState);

protected:
  virtual ~PresShell();

@@ -889,6 +891,8 @@ protected:
  // Whether the widget has received a paint message yet.
  bool                      mHasReceivedPaintMessage : 1;

  bool                      mInImageVisibility : 1;

  static bool               sDisableNonTestMouseEvents;
};