This commit is contained in:
Ehsan Akhgari 2015-05-14 15:53:50 -04:00
Родитель 909a826cf5 0e358a231a
Коммит 186a054e96
14 изменённых файлов: 105 добавлений и 107 удалений

Просмотреть файл

@ -8585,7 +8585,9 @@ else
# so if the file is named libsomething.so. The lib/ path is also required
# because the unpacked file will be under the lib/ subdirectory and will
# need to be executed from that path.
MOZ_CHILD_PROCESS_NAME="lib/libplugin-container.so"
MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
MOZ_CHILD_PROCESS_NAME_PIE="libplugin-container-pie.so"
AC_SUBST(MOZ_CHILD_PROCESS_NAME_PIE)
fi
MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"

Просмотреть файл

@ -33,6 +33,10 @@
#include "prlog.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
struct JSContext;
class JSObject;
@ -87,7 +91,12 @@ IsTypeSupported(const nsAString& aType)
if (mimeType.EqualsASCII(gMediaSourceTypes[i])) {
if ((mimeType.EqualsASCII("video/mp4") ||
mimeType.EqualsASCII("audio/mp4")) &&
!Preferences::GetBool("media.mediasource.mp4.enabled", false)) {
(!Preferences::GetBool("media.mediasource.mp4.enabled", false)
#ifdef MOZ_WIDGET_ANDROID
// MP4 won't work unless we have JellyBean+
|| AndroidBridge::Bridge()->GetAPIVersion() < 16
#endif
)) {
break;
}
if ((mimeType.EqualsASCII("video/webm") ||

Просмотреть файл

@ -689,7 +689,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"MediaRecorder",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaSource", android: false, linux: false, release: false},
{name: "MediaSource", android: true, linux: false, release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
"MediaStream",
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -933,9 +933,9 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "SimpleTest", xbl: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "SourceBuffer", android: false, linux: false, release: false},
{name: "SourceBuffer", android: true, linux: false, release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "SourceBufferList", android: false, linux: false, release: false},
{name: "SourceBufferList", android: true, linux: false, release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "SpeechSynthesisEvent", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -1287,7 +1287,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"ValidityState",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "VideoPlaybackQuality", android: false, linux: false, release: false},
{name: "VideoPlaybackQuality", android: true, linux: false, release: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
"VideoStreamTrack",
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -1390,8 +1390,8 @@ function createInterfaceMap(isXBLScope) {
var isB2G = !isDesktop && !navigator.userAgent.includes("Android");
var isMac = /Mac OS/.test(navigator.oscpu);
var isWindows = /Windows/.test(navigator.oscpu);
var isLinux = /Linux/.test(navigator.oscpu);
var isAndroid = navigator.userAgent.includes("Android");
var isLinux = /Linux/.test(navigator.oscpu) && !isAndroid;
var hasPermission = function (aPermissions) {
var result = false;
for (var p of aPermissions) {

Просмотреть файл

@ -2,10 +2,6 @@
# 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/.
ifneq ($(dir $(PROGRAM)),./)
GENERATED_DIRS = $(dir $(PROGRAM))
endif
ifndef MOZ_WINCONSOLE
ifdef MOZ_DEBUG
MOZ_WINCONSOLE = 1

Просмотреть файл

@ -4,11 +4,15 @@
# 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/.
# Any changes that affect Android need to be made in pie/moz.build as well.
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
Program(CONFIG['MOZ_CHILD_PROCESS_NAME'])
SOURCES += [
'MozillaRuntimeMainAndroid.cpp',
]
DIRS += ['pie']
else:
kwargs = {
'linkage': None,

32
ipc/app/pie/moz.build Normal file
Просмотреть файл

@ -0,0 +1,32 @@
# -*- Mode: python; c-basic-offset: 4; 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/.
Program(CONFIG['MOZ_CHILD_PROCESS_NAME_PIE'])
SOURCES += [
'../MozillaRuntimeMainAndroid.cpp',
]
include('/ipc/chromium/chromium-config.mozbuild')
LOCAL_INCLUDES += [
'/toolkit/xre',
'/xpcom/base',
]
if CONFIG['MOZ_SANDBOX']:
USE_LIBS += [
'mozsandbox',
]
# gcc lto likes to put the top level asm in syscall.cc in a different partition
# from the function using it which breaks the build. Work around that by
# forcing there to be only one partition.
if '-flto' in CONFIG['OS_CXXFLAGS'] and not CONFIG['CLANG_CXX']:
LDFLAGS += ['--param lto-partitions=1']
LDFLAGS += ['-pie']
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -57,6 +57,10 @@ using mozilla::ipc::GeckoChildProcessHost;
static const int kMagicAndroidSystemPropFd = 5;
#endif
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
static const bool kLowRightsSubprocesses =
// We currently only attempt to drop privileges on gonk, because we
// have no plugins or extensions to worry about breaking.
@ -164,7 +168,17 @@ GeckoChildProcessHost::GetPathToBinary(FilePath& exePath)
exePath = exePath.DirName();
}
#ifdef MOZ_WIDGET_ANDROID
exePath = exePath.AppendASCII("lib");
// We must use the PIE binary on 5.0 and higher
const char* processName = mozilla::AndroidBridge::Bridge()->GetAPIVersion() >= 21 ?
MOZ_CHILD_PROCESS_NAME_PIE : MOZ_CHILD_PROCESS_NAME;
exePath = exePath.AppendASCII(processName);
#else
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
#endif
}
#ifdef MOZ_WIDGET_COCOA

Просмотреть файл

@ -157,8 +157,8 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
for var in ('MOZ_CHILD_PROCESS_NAME', 'MOZ_CHILD_PROCESS_BUNDLE',
'DLL_PREFIX', 'DLL_SUFFIX'):
for var in ('MOZ_CHILD_PROCESS_NAME', 'MOZ_CHILD_PROCESS_NAME_PIE',
'MOZ_CHILD_PROCESS_BUNDLE', 'DLL_PREFIX', 'DLL_SUFFIX'):
DEFINES[var] = '"%s"' % CONFIG[var]
LOCAL_INCLUDES += [

Просмотреть файл

@ -195,7 +195,7 @@ public:
&format);
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, CreateVideoFormat failed err = %d", __FUNCTION__, res);
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, CreateVideoFormat failed err = %d", __FUNCTION__, (int)res);
return NS_ERROR_FAILURE;
}
@ -203,7 +203,7 @@ public:
mCoder = CreateEncoder(mime);
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, CreateEncoderByType failed err = %d", __FUNCTION__, res);
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, CreateEncoderByType failed err = %d", __FUNCTION__, (int)res);
return NS_ERROR_FAILURE;
}
@ -216,13 +216,13 @@ public:
} else {
mCoder = CreateDecoder(mime);
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, CreateDecoderByType failed err = %d", __FUNCTION__, res);
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, CreateDecoderByType failed err = %d", __FUNCTION__, (int)res);
return NS_ERROR_FAILURE;
}
}
res = mCoder->Configure(format, nullptr, nullptr, flags);
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, err = %d", __FUNCTION__, res);
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, err = %d", __FUNCTION__, (int)res);
}
}
@ -242,7 +242,7 @@ public:
res = mCoder->Start();
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, mCoder->start() return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return res;
}
isStarted = true;
@ -361,7 +361,7 @@ public:
res = BufferInfo::New(&bufferInfo);
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, BufferInfo::New return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return res;
}
int32_t outputIndex = DequeueOutputBuffer(bufferInfo);
@ -421,7 +421,7 @@ public:
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, mCoder->DequeueInputBuffer() return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return -1;
}
return inputIndex;
@ -433,7 +433,7 @@ public:
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, mCoder->QueueInputBuffer() return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
}
}
@ -445,7 +445,7 @@ public:
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, mCoder->DequeueOutputBuffer() return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return -1;
}
@ -469,7 +469,7 @@ public:
mInputBuffers = (jobjectArray) env->NewGlobalRef(inputBuffers.Get());
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, GetInputBuffers return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return nullptr;
}
@ -489,7 +489,7 @@ public:
mOutputBuffers = (jobjectArray) env->NewGlobalRef(outputBuffers.Get());
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcAndroidMediaCodec::%s, GetOutputBuffers return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return nullptr;
}
@ -653,7 +653,7 @@ int32_t WebrtcMediaCodecVP8VideoEncoder::Encode(
if (res != NS_OK) {
CSFLogDebug(logTag, "%s, encoder configure return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return WEBRTC_VIDEO_CODEC_ERROR;
}
@ -661,7 +661,7 @@ int32_t WebrtcMediaCodecVP8VideoEncoder::Encode(
if (NS_FAILED(res)) {
mMediaCodecEncoder->isStarted = false;
CSFLogDebug(logTag, "%s start encoder. err = %d", __FUNCTION__, res);
CSFLogDebug(logTag, "%s start encoder. err = %d", __FUNCTION__, (int)res);
return WEBRTC_VIDEO_CODEC_ERROR;
}
@ -732,7 +732,7 @@ int32_t WebrtcMediaCodecVP8VideoEncoder::Encode(
res = BufferInfo::New(&bufferInfo);
if (NS_FAILED(res)) {
CSFLogDebug(logTag, "WebrtcMediaCodecVP8VideoEncoder::%s, BufferInfo::New return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return -1;
}
@ -928,7 +928,7 @@ int32_t WebrtcMediaCodecVP8VideoDecoder::Decode(
if (res != NS_OK) {
CSFLogDebug(logTag, "%s, decoder configure return err = %d",
__FUNCTION__, res);
__FUNCTION__, (int)res);
return WEBRTC_VIDEO_CODEC_ERROR;
}
@ -936,7 +936,7 @@ int32_t WebrtcMediaCodecVP8VideoDecoder::Decode(
if (NS_FAILED(res)) {
mMediaCodecDecoder->isStarted = false;
CSFLogDebug(logTag, "%s start decoder. err = %d", __FUNCTION__, res);
CSFLogDebug(logTag, "%s start decoder. err = %d", __FUNCTION__, (int)res);
return WEBRTC_VIDEO_CODEC_ERROR;
}

Просмотреть файл

@ -569,6 +569,9 @@ pref("media.fragmented-mp4.enabled", true);
pref("media.fragmented-mp4.android-media-codec.enabled", true);
pref("media.fragmented-mp4.android-media-codec.preferred", true);
// Enable MSE
pref("media.mediasource.enabled", true);
// optimize images memory usage
pref("image.downscale-during-decode.enabled", true);
pref("image.decode-only-on-draw.enabled", true);

Просмотреть файл

@ -20,48 +20,6 @@ import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
/**
* EGLPreloadingThread is purely a preloading optimization, not something
* we rely on for anything else than performance. We will be initializing
* EGL in GLController::initEGL() when we need it, but having EGL initialization
* already previously done by EGLPreloadingThread::run() will make it much
* faster for GLController to do again.
*
* For example, here are some timings recorded on two devices:
*
* Device | EGLPreloadingThread::run() | GLController::initEGL()
* -----------------------+----------------------------+------------------------
* Nexus S (Android 2.3) | ~ 80 ms | < 0.1 ms
* Nexus 10 (Android 4.3) | ~ 35 ms | < 0.1 ms
*/
class EGLPreloadingThread extends Thread
{
private static final String LOGTAG = "EGLPreloadingThread";
private EGL10 mEGL;
private EGLDisplay mEGLDisplay;
public EGLPreloadingThread()
{
}
@Override
public void run()
{
mEGL = (EGL10)EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
Log.w(LOGTAG, "Can't get EGL display!");
return;
}
int[] returnedVersion = new int[2];
if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) {
Log.w(LOGTAG, "eglInitialize failed");
return;
}
}
}
/**
* This class is a singleton that tracks EGL and compositor things over
* the lifetime of Fennec running.
@ -89,7 +47,6 @@ public class GLController {
private EGL10 mEGL;
private EGLDisplay mEGLDisplay;
private EGLConfig mEGLConfig;
private final EGLPreloadingThread mEGLPreloadingThread;
private EGLSurface mEGLSurfaceForCompositor;
private static final int LOCAL_EGL_OPENGL_ES2_BIT = 4;
@ -113,12 +70,6 @@ public class GLController {
};
private GLController() {
if (AppConstants.Versions.preICS) {
mEGLPreloadingThread = new EGLPreloadingThread();
mEGLPreloadingThread.start();
} else {
mEGLPreloadingThread = null;
}
}
static GLController getInstance(LayerView view) {
@ -211,19 +162,6 @@ public class GLController {
return;
}
// This join() should not be necessary, but makes this code a bit easier to think about.
// The EGLPreloadingThread should long be done by now, and even if it's not,
// it shouldn't be a problem to be initializing EGL from two different threads.
// Still, having this join() here means that we don't have to wonder about what
// kind of caveats might exist with EGL initialization reentrancy on various drivers.
if (mEGLPreloadingThread != null) {
try {
mEGLPreloadingThread.join();
} catch (InterruptedException e) {
Log.w(LOGTAG, "EGLPreloadingThread interrupted", e);
}
}
mEGL = (EGL10)EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
@ -232,20 +170,18 @@ public class GLController {
return;
}
if (AppConstants.Versions.preICS) {
// while calling eglInitialize here should not be necessary as it was already called
// by the EGLPreloadingThread, it really doesn't cost much to call it again here,
// and makes this code easier to think about: EGLPreloadingThread is only a
// preloading optimization, not something we rely on for anything else.
//
// Also note that while calling eglInitialize isn't necessary on Android 4.x
// (at least Android's HardwareRenderer does it for us already), it is necessary
// on Android 2.x.
int[] returnedVersion = new int[2];
if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) {
Log.w(LOGTAG, "eglInitialize failed");
return;
}
// while calling eglInitialize here should not be necessary as it was already called
// by the EGLPreloadingThread, it really doesn't cost much to call it again here,
// and makes this code easier to think about: EGLPreloadingThread is only a
// preloading optimization, not something we rely on for anything else.
//
// Also note that while calling eglInitialize isn't necessary on Android 4.x
// (at least Android's HardwareRenderer does it for us already), it is necessary
// on Android 2.x.
int[] returnedVersion = new int[2];
if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) {
Log.w(LOGTAG, "eglInitialize failed");
return;
}
mEGLConfig = chooseConfig();

Просмотреть файл

@ -49,7 +49,7 @@ package: local.properties project.properties AndroidManifest.xml FORCE
# Copy the SOs. The latter should be $(MOZ_CHILD_PROCESS_NAME), but
# it includes a "lib/" prefix.
cp $(_ABS_DIST)/bin/libmozglue.so $(_ABS_DIST)/bin/libplugin-container.so libs/$(ANDROID_CPU_ARCH)/
cp $(addprefix $(_ABS_DIST)/bin/,libmozglue.so $(MOZ_CHILD_PROCESS_NAME) $(MOZ_CHILD_PROCESS_NAME_PIE)) libs/$(ANDROID_CPU_ARCH)/
# Copy the resources
$(RM) -rf res

Просмотреть файл

@ -23,6 +23,7 @@ DEFINES += \
-DPREF_DIR=$(PREF_DIR) \
-DJAREXT= \
-DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME) \
-DMOZ_CHILD_PROCESS_NAME_PIE=$(MOZ_CHILD_PROCESS_NAME_PIE) \
-DANDROID_CPU_ARCH=$(ANDROID_CPU_ARCH) \
$(NULL)

Просмотреть файл

@ -76,7 +76,8 @@
[lib destdir="lib/@ANDROID_CPU_ARCH@"]
@BINPATH@/@DLL_PREFIX@mozglue@DLL_SUFFIX@
# This should be MOZ_CHILD_PROCESS_NAME, but that has a "lib/" prefix.
@BINPATH@/@DLL_PREFIX@plugin-container@DLL_SUFFIX@
@BINPATH@/@MOZ_CHILD_PROCESS_NAME@
@BINPATH@/@MOZ_CHILD_PROCESS_NAME_PIE@
[xpcom]
@BINPATH@/dependentlibs.list