forked from mirrors/gecko-dev
On some Android devices (predominantly Huawei devices running Android 9 or below) we are seeing large numbers of crashes due to the compositor being unable to create an EGL surface to render in to. From local testing, this appears to be due to the Surface we are being provided from the SurfaceView being in an "abandoned" state. Presumably this is due to an operating system bug - the Surface is valid at the time of the surfaceChanged() callback, but becomes abandoned moments later despite surfaceDestroyed() not being called. We are able to detect when the Surface is in such a state from C++ code by calling ANativeWindow_getWidth(), as that will return a negative value to indicate an error. This patch uses this method to check whether the Surface is in such a state prior to resuming the compositor. If so, rather than immediately resuming the compositor it instead toggles the SurfaceView's visibility. This tricks the SurfaceView in to providing a new (and hopefully valid) Surface, which will in turn resume the compositor via the surfaceChanged callback. Differential Revision: https://phabricator.services.mozilla.com/D151479
205 lines
4.8 KiB
Python
205 lines
4.8 KiB
Python
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
|
# vim: set filetype=python:
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
with Files("**"):
|
|
BUG_COMPONENT = ("Core", "Widget: Android")
|
|
SCHEDULES.exclusive = ["android"]
|
|
|
|
with Files("*CompositorWidget*"):
|
|
BUG_COMPONENT = ("Core", "Graphics")
|
|
|
|
DIRS += [
|
|
"bindings",
|
|
"jni",
|
|
]
|
|
|
|
XPIDL_SOURCES += [
|
|
"nsIAndroidBridge.idl",
|
|
]
|
|
|
|
XPIDL_MODULE = "widget_android"
|
|
|
|
EXPORTS += [
|
|
"AndroidBridge.h",
|
|
]
|
|
|
|
classes_with_WrapForJNI = [
|
|
"AndroidGamepadManager",
|
|
"AndroidVsync",
|
|
"Base64Utils",
|
|
"Clipboard",
|
|
"CodecProxy",
|
|
"CompositorSurfaceManager",
|
|
"EnterpriseRoots",
|
|
"EventCallback",
|
|
"EventDispatcher",
|
|
"GeckoAppShell",
|
|
"GeckoAudioInfo",
|
|
"GeckoBatteryManager",
|
|
"GeckoBundle",
|
|
"GeckoEditableChild",
|
|
"GeckoHLSDemuxerWrapper",
|
|
"GeckoHLSResourceWrapper",
|
|
"GeckoHLSSample",
|
|
"GeckoInputStream",
|
|
"GeckoJavaSampler",
|
|
"GeckoNetworkManager",
|
|
"GeckoProcessManager",
|
|
"GeckoProcessType",
|
|
"GeckoResult",
|
|
"GeckoRuntime",
|
|
"GeckoServiceChildProcess",
|
|
"GeckoServiceGpuProcess",
|
|
"GeckoSession",
|
|
"GeckoSurface",
|
|
"GeckoSurfaceTexture",
|
|
"GeckoSystemStateListener",
|
|
"GeckoThread",
|
|
"GeckoVRManager",
|
|
"GeckoVideoInfo",
|
|
"GeckoWebExecutor",
|
|
"HardwareCodecCapabilityUtils",
|
|
"Image",
|
|
"ImageDecoder",
|
|
"MediaDrmProxy",
|
|
"PanZoomController",
|
|
"RuntimeTelemetry",
|
|
"Sample",
|
|
"SampleBuffer",
|
|
"ScreenManagerHelper",
|
|
"ServiceAllocator",
|
|
"SessionAccessibility",
|
|
"SessionKeyInfo",
|
|
"SessionTextInput",
|
|
"SpeechSynthesisService",
|
|
"SurfaceAllocator",
|
|
"SurfaceControlManager",
|
|
"SurfaceTextureListener",
|
|
"SurfaceViewWrapper",
|
|
"TelemetryUtils",
|
|
"WebAuthnTokenManager",
|
|
"WebMessage",
|
|
"WebNotification",
|
|
"WebNotificationDelegate",
|
|
"WebRequest",
|
|
"WebRequestError",
|
|
"WebResponse",
|
|
"XPCOMEventTarget",
|
|
]
|
|
|
|
natives_from_WrapForJNI = sorted(
|
|
["GeneratedJNI/{}Natives.h".format(c) for c in classes_with_WrapForJNI]
|
|
)
|
|
|
|
wrappers_from_WrapForJNI = sorted(
|
|
["GeneratedJNI/{}Wrappers.h".format(c) for c in classes_with_WrapForJNI]
|
|
)
|
|
|
|
sources_from_WrapForJNI = sorted(
|
|
"GeneratedJNI{}Wrappers.cpp".format(c) for c in classes_with_WrapForJNI
|
|
)
|
|
|
|
EXPORTS.mozilla.widget += [
|
|
"AndroidCompositorWidget.h",
|
|
"AndroidUiThread.h",
|
|
"AndroidView.h",
|
|
"AndroidVsync.h",
|
|
"CompositorWidgetChild.h",
|
|
"CompositorWidgetParent.h",
|
|
"EventDispatcher.h",
|
|
"GeckoViewSupport.h",
|
|
"InProcessAndroidCompositorWidget.h",
|
|
"nsWindow.h",
|
|
"WindowEvent.h",
|
|
]
|
|
|
|
EXPORTS.mozilla.java += ["!{}".format(c) for c in natives_from_WrapForJNI]
|
|
|
|
EXPORTS.mozilla.java += ["!{}".format(c) for c in wrappers_from_WrapForJNI]
|
|
|
|
SOURCES += ["!{}".format(c) for c in sources_from_WrapForJNI]
|
|
|
|
SOURCES += [
|
|
"MediaKeysEventSourceFactory.cpp",
|
|
]
|
|
|
|
UNIFIED_SOURCES += [
|
|
"AndroidAlerts.cpp",
|
|
"AndroidBridge.cpp",
|
|
"AndroidCompositorWidget.cpp",
|
|
"AndroidContentController.cpp",
|
|
"AndroidUiThread.cpp",
|
|
"AndroidVsync.cpp",
|
|
"CompositorWidgetChild.cpp",
|
|
"CompositorWidgetParent.cpp",
|
|
"EventDispatcher.cpp",
|
|
"GeckoEditableSupport.cpp",
|
|
"GeckoProcessManager.cpp",
|
|
"GfxInfo.cpp",
|
|
"ImageDecoderSupport.cpp",
|
|
"InProcessAndroidCompositorWidget.cpp",
|
|
"nsAppShell.cpp",
|
|
"nsClipboard.cpp",
|
|
"nsDeviceContextAndroid.cpp",
|
|
"nsLookAndFeel.cpp",
|
|
"nsPrintSettingsServiceAndroid.cpp",
|
|
"nsUserIdleServiceAndroid.cpp",
|
|
"nsWidgetFactory.cpp",
|
|
"nsWindow.cpp",
|
|
"ScreenHelperAndroid.cpp",
|
|
"WebExecutorSupport.cpp",
|
|
]
|
|
|
|
XPCOM_MANIFESTS += [
|
|
"components.conf",
|
|
]
|
|
|
|
include("/ipc/chromium/chromium-config.mozbuild")
|
|
|
|
# The recursive make backend treats the first output specially: it's passed as
|
|
# an open FileAvoidWrite to the invoked script. That doesn't work well with
|
|
# the Gradle task that generates all of the outputs, so we add a dummy first
|
|
# output.
|
|
|
|
t = tuple(
|
|
["generated_jni_wrappers"]
|
|
+ natives_from_WrapForJNI
|
|
+ sources_from_WrapForJNI
|
|
+ wrappers_from_WrapForJNI
|
|
)
|
|
|
|
GeneratedFile(
|
|
*t,
|
|
script="/mobile/android/gradle.py",
|
|
entry_point="generate_generated_jni_wrappers"
|
|
)
|
|
|
|
FINAL_LIBRARY = "xul"
|
|
|
|
LOCAL_INCLUDES += [
|
|
"/docshell/base",
|
|
"/dom/base",
|
|
"/dom/system/android",
|
|
"/gfx/2d",
|
|
"/gfx/vr",
|
|
"/layout/forms",
|
|
"/layout/painting",
|
|
"/netwerk/base",
|
|
"/netwerk/cache",
|
|
"/toolkit/components/telemetry",
|
|
"/widget",
|
|
"/widget/headless",
|
|
"/xpcom/threads",
|
|
]
|
|
|
|
OS_LIBS += ["android"]
|
|
|
|
if CONFIG["MOZ_NATIVE_DEVICES"]:
|
|
DEFINES["MOZ_NATIVE_DEVICES"] = True
|
|
|
|
# DEFINES['DEBUG_WIDGETS'] = True
|
|
|
|
REQUIRES_UNIFIED_BUILD = True
|