From 9b0dfb4e5fa7c6e90acd6119bff430e40f747d03 Mon Sep 17 00:00:00 2001 From: Mason Chang Date: Sat, 14 Mar 2015 21:23:53 -0700 Subject: [PATCH] Bug 1142957 Fallback to main display CVDisplayLink if active displays aren't available. r=mstange --- gfx/thebes/VsyncSource.cpp | 4 ++++ gfx/thebes/gfxPlatformMac.cpp | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/VsyncSource.cpp b/gfx/thebes/VsyncSource.cpp index a2d378b486f..8624c649213 100644 --- a/gfx/thebes/VsyncSource.cpp +++ b/gfx/thebes/VsyncSource.cpp @@ -124,6 +124,10 @@ VsyncSource::Display::UpdateVsyncStatus() } else { DisableVsync(); } + + if (IsVsyncEnabled() != enableVsync) { + NS_WARNING("Vsync status did not change."); + } } nsRefPtr diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index 65f030150fb..d57434c39c3 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -469,18 +469,31 @@ public: // situations. According to the docs, it is compatible with all displays running on the computer // But if we have different monitors at different display rates, we may hit issues. if (CVDisplayLinkCreateWithActiveCGDisplays(&mDisplayLink) != kCVReturnSuccess) { - NS_WARNING("Could not create a display link, returning"); - return; + NS_WARNING("Could not create a display link with all active displays. Falling back to main display\n"); + CVDisplayLinkRelease(mDisplayLink); + + // bug 1142708 - When coming back from sleep, there may be no active displays ready yet, + // even if listening for the kIOMessageSystemHasPoweredOn event from OS X sleep notifications. + // Active displays are those that are drawable. + // In these cases, default back to the main display to try to get a vsync event. + // The alternative would be to keep polling the CGActiveDisplayList for the displays to be ready. + if (CVDisplayLinkCreateWithCGDisplay(CGMainDisplayID(), &mDisplayLink) != kCVReturnSuccess) { + MOZ_CRASH("Could not create a CVDisplayLink with either active displays or the main display"); + } + NS_WARNING("Using the CVDisplayLink from the main display\n"); } if (CVDisplayLinkSetOutputCallback(mDisplayLink, &VsyncCallback, this) != kCVReturnSuccess) { NS_WARNING("Could not set displaylink output callback"); + CVDisplayLinkRelease(mDisplayLink); + mDisplayLink = nullptr; return; } mPreviousTimestamp = TimeStamp::Now(); if (CVDisplayLinkStart(mDisplayLink) != kCVReturnSuccess) { NS_WARNING("Could not activate the display link"); + CVDisplayLinkRelease(mDisplayLink); mDisplayLink = nullptr; } }