Backed out changeset 4f5a93b89b2b (bug 1344892) for Mochitest rc4 failures in Android
This commit is contained in:
@@ -30,7 +30,6 @@ public class AnnotationInfo {
|
||||
|
||||
public enum DispatchTarget {
|
||||
GECKO,
|
||||
GECKO_PRIORITY,
|
||||
PROXY,
|
||||
CURRENT;
|
||||
|
||||
|
||||
@@ -780,7 +780,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
|
||||
return ((System.nanoTime() - lastStartTimeReRender) < MINIMUM_DELAY_BETWEEN_TWO_RENDER_CALLS_NS);
|
||||
}
|
||||
|
||||
@WrapForJNI(dispatchTo = "gecko_priority")
|
||||
@WrapForJNI(dispatchTo = "gecko")
|
||||
private static native void requestZoomedViewData(ByteBuffer buffer, int tabId,
|
||||
int xPos, int yPos, int width,
|
||||
int height, float scale);
|
||||
|
||||
@@ -129,11 +129,11 @@ public class AndroidGamepadManager {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko_priority")
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
|
||||
private static native void onGamepadChange(int id, boolean added);
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko_priority")
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
|
||||
private static native void onButtonChange(int id, int button, boolean pressed, float value);
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko_priority")
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
|
||||
private static native void onAxisChange(int id, boolean[] valid, float[] values);
|
||||
|
||||
private static boolean sStarted;
|
||||
|
||||
@@ -250,7 +250,11 @@ public class GeckoAppShell
|
||||
return sLayerView;
|
||||
}
|
||||
|
||||
@WrapForJNI(stubName = "NotifyObservers", dispatchTo = "gecko")
|
||||
// Synchronously notify a Gecko observer; must be called from Gecko thread.
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static native void syncNotifyObservers(String topic, String data);
|
||||
|
||||
@WrapForJNI(stubName = "NotifyObservers", dispatchTo = "proxy")
|
||||
private static native void nativeNotifyObservers(String topic, String data);
|
||||
|
||||
@RobocopTarget
|
||||
|
||||
@@ -30,11 +30,8 @@ public @interface WrapForJNI {
|
||||
|
||||
/**
|
||||
* Action to take if member access returns an exception.
|
||||
* - "abort" will cause a crash if there is a pending exception.
|
||||
* - "ignore" will not handle any pending exceptions; it is then the caller's
|
||||
* responsibility to handle exceptions.
|
||||
* - "nsresult" will clear any pending exceptions and return an error code; not
|
||||
* supported for native methods.
|
||||
* One of "abort", "ignore", or "nsresult". "nsresult" is not supported for native
|
||||
* methods.
|
||||
*/
|
||||
String exceptionMode() default "abort";
|
||||
|
||||
@@ -46,15 +43,9 @@ public @interface WrapForJNI {
|
||||
|
||||
/**
|
||||
* The thread that the method call will be dispatched to.
|
||||
* - "current" indicates no dispatching; only supported value for fields,
|
||||
* constructors, non-native methods, and non-void native methods.
|
||||
* - "gecko" indicates dispatching to the Gecko XPCOM (nsThread) event queue.
|
||||
* - "gecko_priority" indicates dispatching to the Gecko widget
|
||||
* (nsAppShell) event queue; in most cases, events in the widget event
|
||||
* queue (aka native event queue) are favored over events in the XPCOM
|
||||
* event queue.
|
||||
* - "proxy" indicates dispatching to a proxy function as a function object; see
|
||||
* widget/jni/Natives.h.
|
||||
* One of "current", "gecko", or "proxy". Not supported for non-native methods,
|
||||
* fields, and constructors. Only void-return methods are supported for anything other
|
||||
* than current thread.
|
||||
*/
|
||||
String dispatchTo() default "current";
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class LayerView extends FrameLayout {
|
||||
/* package */ native void attachToJava(GeckoLayerClient layerClient,
|
||||
NativePanZoomController npzc);
|
||||
|
||||
@WrapForJNI(calledFrom = "any", dispatchTo = "gecko_priority")
|
||||
@WrapForJNI(calledFrom = "any", dispatchTo = "gecko")
|
||||
/* package */ native void onSizeChanged(int windowWidth, int windowHeight,
|
||||
int screenWidth, int screenHeight);
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ class NativePanZoomController extends JNIObject implements PanZoomController {
|
||||
mDestroyed = false;
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko_priority") @Override // JNIObject
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko") @Override // JNIObject
|
||||
protected native void disposeNative();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -650,7 +650,7 @@ public:
|
||||
// Invoke callbacks synchronously if we're already on Gecko thread.
|
||||
return aCall();
|
||||
}
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(Move(aCall)));
|
||||
nsAppShell::PostEvent(Move(aCall));
|
||||
}
|
||||
|
||||
static void Finalize(const CallbackDelegate::LocalRef& aInstance)
|
||||
|
||||
@@ -101,7 +101,7 @@ template<class Impl>
|
||||
class GeckoAppShell::Natives : public mozilla::jni::NativeImpl<GeckoAppShell, Impl>
|
||||
{
|
||||
public:
|
||||
static const JNINativeMethod methods[7];
|
||||
static const JNINativeMethod methods[8];
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
@@ -133,7 +133,11 @@ const JNINativeMethod GeckoAppShell::Natives<Impl>::methods[] = {
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoAppShell::ReportJavaCrash_t>(
|
||||
mozilla::jni::NativeStub<GeckoAppShell::ReportJavaCrash_t, Impl>
|
||||
::template Wrap<&Impl::ReportJavaCrash>)
|
||||
::template Wrap<&Impl::ReportJavaCrash>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoAppShell::SyncNotifyObservers_t>(
|
||||
mozilla::jni::NativeStub<GeckoAppShell::SyncNotifyObservers_t, Impl>
|
||||
::template Wrap<&Impl::SyncNotifyObservers>)
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
|
||||
@@ -668,6 +668,9 @@ auto GeckoAppShell::StartGeckoServiceChildProcess(mozilla::jni::String::Param a0
|
||||
return mozilla::jni::Method<StartGeckoServiceChildProcess_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::SyncNotifyObservers_t::name[];
|
||||
constexpr char GeckoAppShell::SyncNotifyObservers_t::signature[];
|
||||
|
||||
constexpr char GeckoAppShell::UnlockProfile_t::name[];
|
||||
constexpr char GeckoAppShell::UnlockProfile_t::signature[];
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::UI;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO_PRIORITY;
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct OnButtonChange_t {
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::UI;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO_PRIORITY;
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct OnGamepadAdded_t {
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::UI;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO_PRIORITY;
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct Start_t {
|
||||
@@ -1500,7 +1500,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
mozilla::jni::DispatchTarget::PROXY;
|
||||
};
|
||||
|
||||
struct NotifyAlertListener_t {
|
||||
@@ -1882,6 +1882,25 @@ public:
|
||||
|
||||
static auto StartGeckoServiceChildProcess(mozilla::jni::String::Param, mozilla::jni::ObjectArray::Param, int32_t, int32_t) -> int32_t;
|
||||
|
||||
struct SyncNotifyObservers_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::String::Param,
|
||||
mozilla::jni::String::Param> Args;
|
||||
static constexpr char name[] = "syncNotifyObservers";
|
||||
static constexpr char signature[] =
|
||||
"(Ljava/lang/String;Ljava/lang/String;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
struct UnlockProfile_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef bool ReturnType;
|
||||
@@ -3914,7 +3933,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO_PRIORITY;
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct Reattach_t {
|
||||
@@ -4055,7 +4074,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::UI;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO_PRIORITY;
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct HandleMotionEvent_t {
|
||||
|
||||
@@ -595,7 +595,7 @@ public:
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO_PRIORITY;
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "mozilla/IndexSequence.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
@@ -503,21 +501,6 @@ struct Dispatcher
|
||||
HasThisArg, Args...>(Forward<ProxyArgs>(args)...));
|
||||
}
|
||||
|
||||
template<class Traits, bool IsStatic = Traits::isStatic,
|
||||
typename ThisArg, typename... ProxyArgs>
|
||||
static typename EnableIf<
|
||||
Traits::dispatchTarget == DispatchTarget::GECKO_PRIORITY, void>::Type
|
||||
Run(ThisArg thisArg, ProxyArgs&&... args)
|
||||
{
|
||||
// For a static method, do not forward the "this arg" (i.e. the class
|
||||
// local ref) if the implementation does not request it. This saves us
|
||||
// a pair of calls to add/delete global ref.
|
||||
DispatchToGeckoPriorityQueue(MakeUnique<ProxyNativeCall<
|
||||
Impl, typename Traits::Owner, IsStatic, HasThisArg,
|
||||
Args...>>(HasThisArg || !IsStatic ? thisArg : nullptr,
|
||||
Forward<ProxyArgs>(args)...));
|
||||
}
|
||||
|
||||
template<class Traits, bool IsStatic = Traits::isStatic,
|
||||
typename ThisArg, typename... ProxyArgs>
|
||||
static typename EnableIf<
|
||||
@@ -527,19 +510,16 @@ struct Dispatcher
|
||||
// For a static method, do not forward the "this arg" (i.e. the class
|
||||
// local ref) if the implementation does not request it. This saves us
|
||||
// a pair of calls to add/delete global ref.
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(ProxyNativeCall<
|
||||
DispatchToGeckoThread(MakeUnique<ProxyNativeCall<
|
||||
Impl, typename Traits::Owner, IsStatic, HasThisArg,
|
||||
Args...>(HasThisArg || !IsStatic ? thisArg : nullptr,
|
||||
Forward<ProxyArgs>(args)...)));
|
||||
Args...>>(HasThisArg || !IsStatic ? thisArg : nullptr,
|
||||
Forward<ProxyArgs>(args)...));
|
||||
}
|
||||
|
||||
template<class Traits, bool IsStatic = false, typename... ProxyArgs>
|
||||
static typename EnableIf<
|
||||
Traits::dispatchTarget == DispatchTarget::CURRENT, void>::Type
|
||||
Run(ProxyArgs&&... args)
|
||||
{
|
||||
MOZ_CRASH("Unreachable code");
|
||||
}
|
||||
Run(ProxyArgs&&... args) {}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -287,7 +287,7 @@ jclass GetClassRef(JNIEnv* aEnv, const char* aClassName)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DispatchToGeckoPriorityQueue(UniquePtr<AbstractCall>&& aCall)
|
||||
void DispatchToGeckoThread(UniquePtr<AbstractCall>&& aCall)
|
||||
{
|
||||
class AbstractCallEvent : public nsAppShell::Event
|
||||
{
|
||||
|
||||
@@ -50,14 +50,9 @@ enum class DispatchTarget
|
||||
// wrapped in a function object and is passed thru UsesNativeCallProxy.
|
||||
// Method must return void.
|
||||
PROXY,
|
||||
// Call is dispatched asynchronously on the Gecko thread to the XPCOM
|
||||
// (nsThread) event queue. Method must return void.
|
||||
// Call is dispatched asynchronously on the Gecko thread. Method must
|
||||
// return void.
|
||||
GECKO,
|
||||
// Call is dispatched asynchronously on the Gecko thread to the widget
|
||||
// (nsAppShell) event queue. In most cases, events in the widget event
|
||||
// queue (aka native event queue) are favored over events in the XPCOM
|
||||
// event queue. Method must return void.
|
||||
GECKO_PRIORITY,
|
||||
};
|
||||
|
||||
|
||||
@@ -138,7 +133,7 @@ struct AbstractCall
|
||||
virtual void operator()() = 0;
|
||||
};
|
||||
|
||||
void DispatchToGeckoPriorityQueue(UniquePtr<AbstractCall>&& aCall);
|
||||
void DispatchToGeckoThread(UniquePtr<AbstractCall>&& aCall);
|
||||
|
||||
/**
|
||||
* Returns whether Gecko is running in a Fennec environment, as determined by
|
||||
|
||||
@@ -254,6 +254,20 @@ public:
|
||||
MOZ_CRASH("Uncaught Java exception");
|
||||
}
|
||||
|
||||
static void SyncNotifyObservers(jni::String::Param aTopic,
|
||||
jni::String::Param aData)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
NotifyObservers(aTopic, aData);
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
static void OnNativeCall(Functor&& aCall)
|
||||
{
|
||||
MOZ_ASSERT(aCall.IsTarget(&NotifyObservers));
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(mozilla::Move(aCall)));
|
||||
}
|
||||
|
||||
static void NotifyObservers(jni::String::Param aTopic,
|
||||
jni::String::Param aData)
|
||||
{
|
||||
|
||||
@@ -852,8 +852,6 @@ public:
|
||||
mozilla::Move(aCall)), &LayerViewEvent::MakeEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Unexpected call");
|
||||
}
|
||||
|
||||
static LayerViewSupport*
|
||||
|
||||
Reference in New Issue
Block a user