Backed out changeset ffeffef36f34 (bug 1344892) on request of developer for issues with Android reftests. r=backout on a CLOSED TREE

This commit is contained in:
Sebastian Hengst 2017-03-10 21:53:00 +01:00
parent 6117caed69
commit 772d7c9a4f
16 changed files with 43 additions and 73 deletions

View File

@ -30,7 +30,6 @@ public class AnnotationInfo {
public enum DispatchTarget {
GECKO,
GECKO_PRIORITY,
PROXY,
CURRENT;

View File

@ -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);

View File

@ -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;

View File

@ -78,7 +78,7 @@ public final class EventDispatcher extends JNIObject {
return mStateHolder.isReady();
}
@WrapForJNI(dispatchTo = "gecko_priority") @Override // JNIObject
@WrapForJNI(dispatchTo = "gecko") @Override // JNIObject
protected native void disposeNative();
@WrapForJNI private static final int DETACHED = 0;
@ -361,7 +361,7 @@ public final class EventDispatcher extends JNIObject {
@WrapForJNI(dispatchTo = "proxy") @Override // EventCallback
public native void sendError(Object response);
@WrapForJNI(dispatchTo = "gecko_priority") @Override // Object
@WrapForJNI(dispatchTo = "gecko") @Override // Object
protected native void finalize();
}

View File

@ -254,7 +254,7 @@ public class GeckoAppShell
@WrapForJNI(calledFrom = "gecko")
public static native void syncNotifyObservers(String topic, String data);
@WrapForJNI(stubName = "NotifyObservers", dispatchTo = "gecko")
@WrapForJNI(stubName = "NotifyObservers", dispatchTo = "proxy")
private static native void nativeNotifyObservers(String topic, String data);
@RobocopTarget

View File

@ -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";
}

View File

@ -72,15 +72,15 @@ public class LayerView extends FrameLayout {
public Compositor() {
}
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko_priority")
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
@Override protected native void disposeNative();
// Gecko thread sets its Java instances; does not block UI thread.
@WrapForJNI(calledFrom = "any", dispatchTo = "gecko_priority")
@WrapForJNI(calledFrom = "any", dispatchTo = "gecko")
/* 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);

View File

@ -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

View File

@ -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)

View File

@ -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 {
@ -239,7 +239,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 GetInstance_t {
@ -351,7 +351,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 SendError_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 {
@ -3856,7 +3856,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 CreateCompositor_t {
@ -3912,7 +3912,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 OnSizeChanged_t {
@ -3933,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 {
@ -4074,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 {

View File

@ -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 =

View File

@ -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

View File

@ -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
{

View File

@ -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

View File

@ -262,6 +262,13 @@ public:
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)
{

View File

@ -852,8 +852,6 @@ public:
mozilla::Move(aCall)), &LayerViewEvent::MakeEvent);
return;
}
MOZ_CRASH("Unexpected call");
}
static LayerViewSupport*