Skip to content

Commit 66bc74f

Browse files
committed
fix: notify for AppRefreshStarted and remove the log for successful refresh request
Currently CLI performs an additional application start when sending refresh notification to the application. The purpose of this additional application start is to ensure that the application will be started when sending the notification no matter if it is currently crashed. However, this additional operation slows down the entire livesync process with around 2-3 seconds per change. The purpose of this PR is to eliminate the delay as posting `AppRefreshStarted` notification from application. CLI starts an observer notification in order to check if the `AppRefreshStarted` will be sent from the application. In case it is sent, CLI refreshes the application via `RefreshRequest` notification. In case a such notification is not sent, CLI restarts the application in 3 seconds (this is the timeout for awaiting the notification from application). Rel to NativeScript/nativescript-cli#4966
1 parent 8394439 commit 66bc74f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/debugging/TNSDebugging.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
// {N} CLI is relying on these messages. Please do not change them!
2323
#define LOG_DEBUGGER_PORT NSLog(@"NativeScript debugger has opened inspector socket on port %d for %@.", currentInspectorPort, [[NSBundle mainBundle] bundleIdentifier])
24-
#define LOG_SUCCESSFULL_REFRESH NSLog(@"Successfully refreshed the application with RefreshRequest."); notify_post(NOTIFICATION("AppRefreshSucceeded"))
2524
#define LOG_FAILED_REFRESH(reason) NSLog(@"Failed to refresh the application with RefreshRequest. Reason: %@", reason); notify_post(NOTIFICATION("AppRefreshFailed"))
2625

2726
// Synchronization object for serializing access to inspector variable and data socket
@@ -433,6 +432,8 @@ static void TNSEnableRemoteInspector(int argc, char** argv,
433432
notify_register_dispatch(
434433
NOTIFICATION("RefreshRequest"), &refreshRequestSubscription,
435434
dispatch_get_main_queue(), ^(int token) {
435+
notify_post(NOTIFICATION("AppRefreshStarted"));
436+
436437
JSGlobalContextRef context = runtime.globalContext;
437438
JSObjectRef globalObject = JSContextGetGlobalObject(context);
438439
JSStringRef liveSyncMethodName = JSStringCreateWithUTF8CString("__onLiveSync");
@@ -460,8 +461,8 @@ static void TNSEnableRemoteInspector(int argc, char** argv,
460461
return;
461462
}
462463

463-
LOG_SUCCESSFULL_REFRESH;
464-
});
464+
notify_post(NOTIFICATION("AppRefreshSucceeded"));
465+
});
465466

466467
int attachRequestSubscription;
467468
notify_register_dispatch(

0 commit comments

Comments
 (0)