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