Bug 1270180: More instances of MOZ_CRASH converted to gfxDevCrash and getting GFX prefix. r?jgilbert
MozReview-Commit-ID: BFUu2JG9Tk2
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -1951,17 +1951,17 @@ DrawTargetCG::GetNativeSurface(NativeSur
#endif
}
void
DrawTargetCG::Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aDrawOptions)
{
- MOZ_CRASH("not completely implemented");
+ MOZ_CRASH("GFX: not completely implemented");
MarkChanged();
CGContextSaveGState(mCg);
if (isGradient(aMask)) {
assert(0);
} else {
if (aMask.GetType() == PatternType::COLOR) {
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -134,16 +134,17 @@ enum class LogReason : int {
InvalidFont,
PAllocTextureBackendMismatch,
GetFontFileDataFailed,
MessageChannelCloseFailure,
TextureAliveAfterShutdown,
InvalidContext,
InvalidCommandList,
AsyncTransactionTimeout,
+ TextureCreation, // 30
// 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/Preferences.cpp
+++ b/gfx/2d/Preferences.cpp
@@ -27,17 +27,17 @@ static Vector<Int32Pref>& Int32Prefs()
}
/* static */
int32_t
PreferenceAccess::RegisterLivePref(const char* aName, int32_t* aVar,
int32_t aDefault)
{
if (!Int32Prefs().append(Int32Pref{ aName, aVar })) {
- MOZ_CRASH();
+ MOZ_CRASH("GFX: RegisterLivePref failure");
}
return aDefault;
}
/* static */
void
PreferenceAccess::SetAccess(PreferenceAccess* aAccess)
{
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -122,18 +122,18 @@ GetAndInitWARPDisplay(GLLibraryEGL& egl,
LOCAL_EGL_NONE };
EGLDisplay display = egl.fGetPlatformDisplayEXT(LOCAL_EGL_PLATFORM_ANGLE_ANGLE,
displayType,
attrib_list);
if (display == EGL_NO_DISPLAY) {
const EGLint err = egl.fGetError();
if (err != LOCAL_EGL_SUCCESS) {
- printf_stderr("Unexpected error: 0x%04x", err);
- MOZ_CRASH("Unexpected error.");
+ gfxCriticalError() << "Unexpected GL error: " << gfx::hexa(err);
+ MOZ_CRASH("GFX: Unexpected GL error.");
}
return EGL_NO_DISPLAY;
}
if (!egl.fInitialize(display, nullptr, nullptr))
return EGL_NO_DISPLAY;
return display;
--- a/gfx/gl/SharedSurfaceD3D11Interop.cpp
+++ b/gfx/gl/SharedSurfaceD3D11Interop.cpp
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SharedSurfaceD3D11Interop.h"
#include <d3d11.h>
#include "gfxPrefs.h"
#include "GLContext.h"
#include "WGLLibrary.h"
+#include "nsPrintfCString.h"
namespace mozilla {
namespace gl {
/*
Sample Code for WGL_NV_DX_interop2:
Example: Render to Direct3D 11 backbuffer with openGL:
@@ -144,75 +145,75 @@ public:
DXGLDevice(WGLLibrary* wgl, const RefPtr<ID3D11Device>& d3d, HANDLE dxglDeviceHandle)
: mWGL(wgl)
, mD3D(d3d)
, mDXGLDeviceHandle(dxglDeviceHandle)
{ }
~DXGLDevice() {
if (!mWGL->fDXCloseDevice(mDXGLDeviceHandle)) {
-#ifdef DEBUG
uint32_t error = GetLastError();
- printf_stderr("wglDXCloseDevice(0x%x) failed: GetLastError(): 0x%x\n",
- mDXGLDeviceHandle, error);
-#endif
- MOZ_CRASH();
+ const nsPrintfCString errorMessage("wglDXCloseDevice(0x%x) failed: "
+ "GetLastError(): 0x%x\n",
+ mDXGLDeviceHandle, error);
+ gfxCriticalError() << errorMessage.BeginReading();
+ MOZ_CRASH("GFX: Problem closing DXGL device");
}
}
HANDLE RegisterObject(void* dxObject, GLuint name, GLenum type, GLenum access) const {
HANDLE ret = mWGL->fDXRegisterObject(mDXGLDeviceHandle, dxObject, name, type,
access);
if (!ret) {
-#ifdef DEBUG
uint32_t error = GetLastError();
- printf_stderr("wglDXRegisterObject(0x%x, 0x%x, %u, 0x%x, 0x%x) failed:"
- " GetLastError(): 0x%x\n", mDXGLDeviceHandle, dxObject, name,
- type, access, error);
-#endif
- MOZ_CRASH();
+ const nsPrintfCString errorMessage("wglDXRegisterObject(0x%x, 0x%x, %u, 0x%x, 0x%x) failed:"
+ " GetLastError(): 0x%x\n",
+ mDXGLDeviceHandle, dxObject, name,
+ type, access, error);
+ gfxCriticalError() << errorMessage.BeginReading();
+ MOZ_CRASH("GFX: Problem registering DXGL device");
}
return ret;
}
bool UnregisterObject(HANDLE hObject) const {
bool ret = mWGL->fDXUnregisterObject(mDXGLDeviceHandle, hObject);
if (!ret) {
-#ifdef DEBUG
uint32_t error = GetLastError();
- printf_stderr("wglDXUnregisterObject(0x%x, 0x%x) failed: GetLastError():"
- " 0x%x\n", mDXGLDeviceHandle, hObject, error);
-#endif
- MOZ_CRASH();
+ const nsPrintfCString errorMessage("wglDXUnregisterObject(0x%x, 0x%x) failed: "
+ "GetLastError(): 0x%x\n",
+ mDXGLDeviceHandle, hObject, error);
+ gfxCriticalError() << errorMessage.BeginReading();
+ MOZ_CRASH("GFX: Problem unregistering DXGL device");
}
return ret;
}
bool LockObject(HANDLE hObject) const {
bool ret = mWGL->fDXLockObjects(mDXGLDeviceHandle, 1, &hObject);
if (!ret) {
-#ifdef DEBUG
uint32_t error = GetLastError();
- printf_stderr("wglDXLockObjects(0x%x, 1, {0x%x}) failed: GetLastError():"
- " 0x%x\n", mDXGLDeviceHandle, hObject, error);
-#endif
- MOZ_CRASH();
+ const nsPrintfCString errorMessage("wglDXLockObjects(0x%x, 1, {0x%x}) "
+ "failed: GetLastError(): 0x%x\n",
+ mDXGLDeviceHandle, hObject, error);
+ gfxCriticalError() << errorMessage.BeginReading();
+ MOZ_CRASH("GFX: Problem locking DXGL device");
}
return ret;
}
bool UnlockObject(HANDLE hObject) const {
bool ret = mWGL->fDXUnlockObjects(mDXGLDeviceHandle, 1, &hObject);
if (!ret) {
-#ifdef DEBUG
uint32_t error = GetLastError();
- printf_stderr("wglDXUnlockObjects(0x%x, 1, {0x%x}) failed: GetLastError():"
- " 0x%x\n", mDXGLDeviceHandle, hObject, error);
-#endif
- MOZ_CRASH();
+ const nsPrintfCString errorMessage("wglDXUnlockObjects(0x%x, 1, {0x%x}) "
+ "failed: GetLastError(): 0x%x\n",
+ mDXGLDeviceHandle, hObject, error);
+ gfxCriticalError() << errorMessage.BeginReading();
+ MOZ_CRASH("GFX: Problem unlocking DXGL device");
}
return ret;
}
};
////////////////////////////////////////////////////////////////////////////////
// Shared Surface
@@ -326,17 +327,17 @@ SharedSurface_D3D11Interop::ProducerAcqu
MOZ_ASSERT(!mLockedForGL);
if (mKeyedMutex) {
const uint64_t keyValue = 0;
const DWORD timeoutMs = 10000;
HRESULT hr = mKeyedMutex->AcquireSync(keyValue, timeoutMs);
if (hr == WAIT_TIMEOUT) {
// Doubt we should do this? Maybe Wait for ever?
- MOZ_CRASH("d3d11Interop timeout");
+ MOZ_CRASH("GFX: d3d11Interop timeout");
}
}
// Now we have the mutex, we can lock for GL.
MOZ_ALWAYS_TRUE(mDXGL->LockObject(mObjectWGL));
mLockedForGL = true;
}
--- a/gfx/layers/ImageDataSerializer.cpp
+++ b/gfx/layers/ImageDataSerializer.cpp
@@ -107,29 +107,29 @@ void ComputeYCbCrOffsets(int32_t yStride
gfx::SurfaceFormat FormatFromBufferDescriptor(const BufferDescriptor& aDescriptor)
{
switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor:
return aDescriptor.get_RGBDescriptor().format();
case BufferDescriptor::TYCbCrDescriptor:
return gfx::SurfaceFormat::YUV;
default:
- MOZ_CRASH();
+ MOZ_CRASH("GFX: FormatFromBufferDescriptor");
}
}
gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor)
{
switch (aDescriptor.type()) {
case BufferDescriptor::TRGBDescriptor:
return aDescriptor.get_RGBDescriptor().size();
case BufferDescriptor::TYCbCrDescriptor:
return aDescriptor.get_YCbCrDescriptor().ySize();
default:
- MOZ_CRASH();
+ MOZ_CRASH("GFX: SizeFromBufferDescriptor");
}
}
uint8_t* GetYChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor)
{
return aBuffer + aDescriptor.yOffset();
}
--- a/gfx/layers/client/TextureClientPool.cpp
+++ b/gfx/layers/client/TextureClientPool.cpp
@@ -67,22 +67,22 @@ static bool TestClientPool(const char* w
}
if (!ok) {
if (actual) {
gfxCriticalError() << "Pool error(" << what << "): "
<< aPool << "-" << aPool->GetFormat() << ", "
<< actual << "-" << actual->GetFormat() << ", "
<< aClient->GetFormat();
- MOZ_CRASH("Crashing with actual");
+ MOZ_CRASH("GFX: Crashing with actual");
} else {
gfxCriticalError() << "Pool error(" << what << "): "
<< aPool << "-" << aPool->GetFormat() << ", nullptr, "
<< aClient->GetFormat();
- MOZ_CRASH("Crashing without actual");
+ MOZ_CRASH("GFX: Crashing without actual");
}
}
return ok;
}
#endif
already_AddRefed<TextureClient>
TextureClientPool::GetTextureClient()
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -264,17 +264,18 @@ CreateBackendIndependentTextureHost(cons
}
case MemoryOrShmem::Tuintptr_t: {
result = new MemoryTextureHost(reinterpret_cast<uint8_t*>(data.get_uintptr_t()),
bufferDesc.desc(),
aFlags);
break;
}
default:
- MOZ_CRASH();
+ gfxCriticalError() << "Failed texture host for backend " << (int)data.type();
+ MOZ_CRASH("GFX: No texture host for backend");
}
break;
}
#ifdef XP_WIN
case SurfaceDescriptor::TSurfaceDescriptorDIB: {
result = new DIBTextureHost(aFlags, aDesc);
break;
}
@@ -372,17 +373,17 @@ TextureSource::TextureSource()
TextureSource::~TextureSource()
{
MOZ_COUNT_DTOR(TextureSource);
}
const char*
TextureSource::Name() const
{
- MOZ_CRASH("TextureSource without class name");
+ MOZ_CRASH("GFX: TextureSource without class name");
return "TextureSource";
}
BufferTextureHost::BufferTextureHost(const BufferDescriptor& aDesc,
TextureFlags aFlags)
: TextureHost(aFlags)
, mCompositor(nullptr)
, mUpdateSerial(1)
@@ -400,17 +401,19 @@ BufferTextureHost::BufferTextureHost(con
}
case BufferDescriptor::TRGBDescriptor: {
const RGBDescriptor& rgb = mDescriptor.get_RGBDescriptor();
mSize = rgb.size();
mFormat = rgb.format();
mHasIntermediateBuffer = rgb.hasIntermediateBuffer();
break;
}
- default: MOZ_CRASH();
+ default:
+ gfxCriticalError() << "Bad buffer host descriptor " << (int)mDescriptor.type();
+ MOZ_CRASH("GFX: Bad descriptor");
}
if (aFlags & TextureFlags::COMPONENT_ALPHA) {
// One texture of a component alpha texture pair will start out all white.
// This hack allows us to easily make sure that white will be uploaded.
// See bug 1138934
mNeedsFullUpdate = true;
}
}
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -142,17 +142,19 @@ struct CompositableTransaction
MOZ_ASSERT(ok);
break;
}
case OpDestroy::TPCompositableChild: {
DebugOnly<bool> ok = CompositableClient::DestroyFallback(actor.get_PCompositableChild());
MOZ_ASSERT(ok);
break;
}
- default: MOZ_CRASH();
+ default:
+ MOZ_CRASH("GFX: IBC Fallback destroy actors");
+ break;
}
}
mDestroyedActors.Clear();
}
OpVector mOperations;
OpDestroyVector mDestroyedActors;
bool mSwapRequired;
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -165,17 +165,19 @@ public:
MOZ_ASSERT(ok);
break;
}
case OpDestroy::TPCompositableChild: {
DebugOnly<bool> ok = CompositableClient::DestroyFallback(actor.get_PCompositableChild());
MOZ_ASSERT(ok);
break;
}
- default: MOZ_CRASH();
+ default:
+ MOZ_CRASH("GFX: SL Fallback destroy actors");
+ break;
}
}
mDestroyedActors.Clear();
}
EditVector mCset;
EditVector mPaints;
OpDestroyVector mDestroyedActors;
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -130,17 +130,17 @@ SharedPlanarYCbCrImage::AllocateAndGetNe
mBufferSize = size;
MappedYCbCrTextureData mapped;
if (mTextureClient->BorrowMappedYCbCrData(mapped)) {
// The caller expects a pointer to the beginning of the writable part of the
// buffer which is where the y channel starts by default.
return mapped.y.data;
} else {
- MOZ_CRASH();
+ MOZ_CRASH("GFX: Cannot borrow mapped YCbCr data");
}
}
bool
SharedPlanarYCbCrImage::AdoptData(const Data &aData)
{
// AdoptData is used to update YUV plane offsets without (re)allocating
// memory previously allocated with AllocateAndGetNewBuffer().
@@ -186,17 +186,18 @@ SharedPlanarYCbCrImage::Allocate(PlanarY
}
MappedYCbCrTextureData mapped;
// The locking here is sort of a lie. The SharedPlanarYCbCrImage just pulls
// pointers out of the TextureClient and keeps them around, which works only
// because the underlyin BufferTextureData is always mapped in memory even outside
// of the lock/unlock interval. That's sad and new code should follow this example.
if (!mTextureClient->Lock(OpenMode::OPEN_READ) || !mTextureClient->BorrowMappedYCbCrData(mapped)) {
- MOZ_CRASH();
+ MOZ_CRASH("GFX: Cannot lock or borrow mapped YCbCr");
+ return false;
}
aData.mYChannel = mapped.y.data;
aData.mCbChannel = mapped.cb.data;
aData.mCrChannel = mapped.cr.data;
// copy some of aData's values in mData (most of them)
mData.mYChannel = aData.mYChannel;
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1729,17 +1729,17 @@ static bool TryCreateTexture2D(ID3D11Dev
RefPtr<ID3D11Texture2D>& texture)
{
// Older Intel driver version (see bug 1221348 for version #s) crash when
// creating a texture with shared keyed mutex and data.
MOZ_SEH_TRY {
return !FAILED(device->CreateTexture2D(desc, data, getter_AddRefs(texture)));
} MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
// For now we want to aggregrate all the crash signature to a known crash.
- MOZ_CRASH("Crash creating texture. See bug 1221348.");
+ gfxDevCrash(LogReason::TextureCreation) << "Crash creating texture. See bug 1221348.";
return false;
}
}
// See bug 1083071. On some drivers, Direct3D 11 CreateShaderResourceView fails
// with E_OUTOFMEMORY.
bool DoesD3D11TextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bindflags)