From 1a84a3d7bb9296266a35df491f47f7c703dda7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Mon, 8 Mar 2021 19:51:50 +0800 Subject: [PATCH] fix reload on non ui thread --- .../devkit/src/main/java/pub/doric/devkit/DoricDev.java | 9 +++++---- doric-iOS/Devkit/Classes/DoricDev.m | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java index 3a8b9ac2..9310c121 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java @@ -233,13 +233,14 @@ public class DoricDev { DoricLog.d("Context source %s in debugging,skip reload", source); } else { DoricLog.d("Context reload :id %s,source %s ", context.getContextId(), source); - context.reload(script); - if (reloadingContexts.get(context.getContextId()) == null) { - reloadingContexts.put(context.getContextId(), context); - } uiHandler.post(new Runnable() { @Override public void run() { + context.reload(script); + if (reloadingContexts.get(context.getContextId()) == null) { + reloadingContexts.put(context.getContextId(), context); + } + for (StatusCallback callback : callbacks) { callback.onReload(context, script); } diff --git a/doric-iOS/Devkit/Classes/DoricDev.m b/doric-iOS/Devkit/Classes/DoricDev.m index 03fca90a..ddf827ee 100644 --- a/doric-iOS/Devkit/Classes/DoricDev.m +++ b/doric-iOS/Devkit/Classes/DoricDev.m @@ -185,9 +185,10 @@ - (void)reload:(NSString *)source script:(NSString *)script { DoricLog(@"Context source %@ in debugging,skip reload", source); } else { DoricLog(@"Context reload :id %@,source %@", context.contextId, source); - [context reload:script]; - [self.reloadingContexts addObject:context]; + dispatch_async(dispatch_get_main_queue(), ^{ + [context reload:script]; + [self.reloadingContexts addObject:context]; for (id callback in self.callbacks) { [callback onReload:context script:script]; }