feat:Android debugging fix issue
This commit is contained in:
parent
936bd60293
commit
741cad2f3e
@ -62,7 +62,7 @@ public class DoricDebugDriver implements IDoricDriver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResult<JSDecoder> invokeDoricMethod(final String method, final Object... args) {
|
public AsyncResult<JSDecoder> invokeDoricMethod(final String method, final Object... args) {
|
||||||
return AsyncCall.ensureRunInExecutor(mBridgeExecutor, new Callable<JSDecoder>() {
|
return asyncCall(new Callable<JSDecoder>() {
|
||||||
@Override
|
@Override
|
||||||
public JSDecoder call() {
|
public JSDecoder call() {
|
||||||
try {
|
try {
|
||||||
@ -72,7 +72,7 @@ public class DoricDebugDriver implements IDoricDriver {
|
|||||||
return new JSDecoder(null);
|
return new JSDecoder(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, ThreadMode.JS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,8 +80,11 @@ public class DoricDebugDriver implements IDoricDriver {
|
|||||||
switch (threadMode) {
|
switch (threadMode) {
|
||||||
case UI:
|
case UI:
|
||||||
return AsyncCall.ensureRunInHandler(mUIHandler, callable);
|
return AsyncCall.ensureRunInHandler(mUIHandler, callable);
|
||||||
case INDEPENDENT:
|
|
||||||
case JS:
|
case JS:
|
||||||
|
if (!doricDebugJSEngine.isInvokingMethod()) {
|
||||||
|
return AsyncCall.ensureRunInHandler(doricDebugJSEngine.getJSHandler(), callable);
|
||||||
|
}
|
||||||
|
case INDEPENDENT:
|
||||||
default:
|
default:
|
||||||
return AsyncCall.ensureRunInExecutor(mBridgeExecutor, callable);
|
return AsyncCall.ensureRunInExecutor(mBridgeExecutor, callable);
|
||||||
}
|
}
|
||||||
@ -89,7 +92,7 @@ public class DoricDebugDriver implements IDoricDriver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResult<Boolean> createContext(final String contextId, final String script, final String source) {
|
public AsyncResult<Boolean> createContext(final String contextId, final String script, final String source) {
|
||||||
return AsyncCall.ensureRunInExecutor(mBridgeExecutor, new Callable<Boolean>() {
|
return asyncCall(new Callable<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean call() {
|
public Boolean call() {
|
||||||
try {
|
try {
|
||||||
@ -100,12 +103,12 @@ public class DoricDebugDriver implements IDoricDriver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, ThreadMode.JS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncResult<Boolean> destroyContext(final String contextId) {
|
public AsyncResult<Boolean> destroyContext(final String contextId) {
|
||||||
return AsyncCall.ensureRunInExecutor(mBridgeExecutor, new Callable<Boolean>() {
|
return asyncCall(new Callable<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean call() {
|
public Boolean call() {
|
||||||
try {
|
try {
|
||||||
@ -118,7 +121,7 @@ public class DoricDebugDriver implements IDoricDriver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, ThreadMode.JS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,4 +31,11 @@ public class DoricDebugJSEngine extends DoricJSEngine {
|
|||||||
protected void initJSEngine() {
|
protected void initJSEngine() {
|
||||||
mDoricJSE = new DoricRemoteJSExecutor(this.wsClient);
|
mDoricJSE = new DoricRemoteJSExecutor(this.wsClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInvokingMethod() {
|
||||||
|
if (mDoricJSE instanceof DoricRemoteJSExecutor) {
|
||||||
|
return ((DoricRemoteJSExecutor) mDoricJSE).isInvokingMethod();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,11 +129,11 @@ public class DoricDev {
|
|||||||
new JSONBuilder()
|
new JSONBuilder()
|
||||||
.put("contextId", context.getContextId())
|
.put("contextId", context.getContextId())
|
||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
debuggable = new DoricContextDebuggable(wsClient, context);
|
|
||||||
debuggable.startDebug();
|
|
||||||
uiHandler.post(new Runnable() {
|
uiHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
debuggable = new DoricContextDebuggable(wsClient, context);
|
||||||
|
debuggable.startDebug();
|
||||||
for (StatusCallback callback : callbacks) {
|
for (StatusCallback callback : callbacks) {
|
||||||
callback.onStartDebugging(context);
|
callback.onStartDebugging(context);
|
||||||
}
|
}
|
||||||
@ -149,16 +149,16 @@ public class DoricDev {
|
|||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopDebugging(boolean resume) {
|
public void stopDebugging(final boolean resume) {
|
||||||
wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder()
|
wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder()
|
||||||
.put("msg", "Stop debugging")
|
.put("msg", "Stop debugging")
|
||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
if (debuggable != null) {
|
if (debuggable != null) {
|
||||||
debuggable.stopDebug(resume);
|
|
||||||
debuggable = null;
|
|
||||||
uiHandler.post(new Runnable() {
|
uiHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
debuggable.stopDebug(resume);
|
||||||
|
debuggable = null;
|
||||||
for (StatusCallback callback : callbacks) {
|
for (StatusCallback callback : callbacks) {
|
||||||
callback.onStopDebugging();
|
callback.onStopDebugging();
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,8 @@ public class DoricRemoteJSExecutor implements IDoricJSE {
|
|||||||
public void teardown() {
|
public void teardown() {
|
||||||
mRemoteJSExecutor.destroy();
|
mRemoteJSExecutor.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInvokingMethod() {
|
||||||
|
return mRemoteJSExecutor.invokingMethod;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ public class RemoteJSExecutor implements WSClient.Interceptor {
|
|||||||
private Map<Integer, Thread> mThreads = new HashMap<>();
|
private Map<Integer, Thread> mThreads = new HashMap<>();
|
||||||
private Map<Integer, JSDecoder> mResults = new HashMap<>();
|
private Map<Integer, JSDecoder> mResults = new HashMap<>();
|
||||||
|
|
||||||
|
public volatile boolean invokingMethod = false;
|
||||||
|
|
||||||
public RemoteJSExecutor(WSClient wsClient) {
|
public RemoteJSExecutor(WSClient wsClient) {
|
||||||
this.wsClient = wsClient;
|
this.wsClient = wsClient;
|
||||||
this.wsClient.addInterceptor(this);
|
this.wsClient.addInterceptor(this);
|
||||||
@ -79,9 +81,11 @@ public class RemoteJSExecutor implements WSClient.Interceptor {
|
|||||||
.put("callId", callId)
|
.put("callId", callId)
|
||||||
.put("hashKey", hashKey)
|
.put("hashKey", hashKey)
|
||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
|
invokingMethod = true;
|
||||||
Thread thread = Thread.currentThread();
|
Thread thread = Thread.currentThread();
|
||||||
mThreads.put(callId, thread);
|
mThreads.put(callId, thread);
|
||||||
LockSupport.park(thread);
|
LockSupport.park(thread);
|
||||||
|
invokingMethod = false;
|
||||||
return mResults.remove(callId);
|
return mResults.remove(callId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
doric-web/dist/index.js
vendored
4
doric-web/dist/index.js
vendored
@ -1327,6 +1327,9 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
const gContexts = new Map;
|
const gContexts = new Map;
|
||||||
const gModules = new Map;
|
const gModules = new Map;
|
||||||
|
function allContexts() {
|
||||||
|
return gContexts.values();
|
||||||
|
}
|
||||||
function jsObtainContext(id) {
|
function jsObtainContext(id) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
const context = gContexts.get(id);
|
const context = gContexts.get(id);
|
||||||
@ -1528,6 +1531,7 @@ var doric = (function (exports) {
|
|||||||
|
|
||||||
exports.Context = Context;
|
exports.Context = Context;
|
||||||
exports.__require__ = __require__;
|
exports.__require__ = __require__;
|
||||||
|
exports.allContexts = allContexts;
|
||||||
exports.jsCallEntityMethod = jsCallEntityMethod;
|
exports.jsCallEntityMethod = jsCallEntityMethod;
|
||||||
exports.jsCallReject = jsCallReject;
|
exports.jsCallReject = jsCallReject;
|
||||||
exports.jsCallResolve = jsCallResolve;
|
exports.jsCallResolve = jsCallResolve;
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user