Bug 776742: ANativeWindow::cancelBuffer now points to a no-op function, fixing a process exit segfault in the emulator. r=cjones
authorMarshall Culpepper <marshall@mozilla.com>
Tue, 07 Aug 2012 15:54:28 -0500
changeset 101717 6ee7b6582fbd620af43f71f17525e674e95d73ef
parent 101716 84739a192aa9baf5f1332d2a6b5f77d7ad2f1a53
child 101718 4e54a6eb43d23d28cfaf9382e1bc6b097728dd24
push id23250
push useremorley@mozilla.com
push dateWed, 08 Aug 2012 16:23:03 +0000
treeherdermozilla-central@b99a81e70b06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs776742
milestone17.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 776742: ANativeWindow::cancelBuffer now points to a no-op function, fixing a process exit segfault in the emulator. r=cjones
widget/gonk/nsWindow.cpp
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -64,23 +64,35 @@ static android::FramebufferNativeWindow 
 static bool sFramebufferOpen;
 static bool sUsingOMTC;
 static bool sScreenInitialized;
 static nsRefPtr<gfxASurface> sOMTCSurface;
 static pthread_t sFramebufferWatchThread;
 
 namespace {
 
+static int
+CancelBufferNoop(ANativeWindow* aWindow, android_native_buffer_t* aBuffer)
+{
+    return 0;
+}
+
 android::FramebufferNativeWindow*
 NativeWindow()
 {
     if (!gNativeWindow) {
         // We (apparently) don't have a way to tell if allocating the
         // fbs succeeded or failed.
         gNativeWindow = new android::FramebufferNativeWindow();
+
+        // Bug 776742: FrambufferNativeWindow doesn't set the cancelBuffer
+        // function pointer, causing EGL to segfault when the window surface
+        // is destroyed (i.e. on process exit). This workaround stops us
+        // from hard crashing in that situation.
+        gNativeWindow->cancelBuffer = CancelBufferNoop;
     }
     return gNativeWindow;
 }
 
 static PRUint32
 EffectiveScreenRotation()
 {
     return (sScreenRotation + sPhysicalScreenRotation) % (360 / 90);