From 3d1bfcf05a412d06ae1dceb1e05ab495b3f38bbc Mon Sep 17 00:00:00 2001 From: Martin Bektchiev Date: Mon, 25 Mar 2019 14:17:22 +0200 Subject: [PATCH 1/3] fix(livesync): `__onLiveSync` function must be called on the UI thread This was no longer happening after merging the fix for #1021 --- .../inspector/InspectorPageAgent.mm | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/NativeScript/inspector/InspectorPageAgent.mm b/src/NativeScript/inspector/InspectorPageAgent.mm index 3549e4539..dc313ff61 100644 --- a/src/NativeScript/inspector/InspectorPageAgent.mm +++ b/src/NativeScript/inspector/InspectorPageAgent.mm @@ -32,21 +32,29 @@ } void InspectorPageAgent::reload(ErrorString&, const bool* const optionalReloadFromOrigin, const bool* const optionalRevalidateAllResources) { - JSC::JSValue liveSyncCallback = m_globalObject.get(m_globalObject.globalExec(), JSC::Identifier::fromString(&m_globalObject.vm(), "__onLiveSync")); - JSC::CallData callData; - JSC::CallType callType = getCallData(m_globalObject.vm(), liveSyncCallback, callData); - if (callType == JSC::CallType::None) { - JSC::JSValue error = JSC::createError(m_globalObject.globalExec(), "global.__onLiveSync is not a function."); - m_globalObject.inspectorController().reportAPIException(m_globalObject.globalExec(), JSC::Exception::create(m_globalObject.globalExec()->vm(), error)); - return; - } - - WTF::NakedPtr exception; - JSC::MarkedArgumentBuffer liveSyncArguments; - call(m_globalObject.globalExec(), liveSyncCallback, callType, callData, JSC::jsUndefined(), liveSyncArguments, exception); - if (exception) { - m_globalObject.inspectorController().reportAPIException(m_globalObject.globalExec(), exception); - } + // __onLiveSync interacts with UI elements and has to be called in the main thread + CFRunLoopRef runloop = CFRunLoopGetMain(); + CFRunLoopPerformBlock(runloop, (__bridge CFTypeRef)(kCFRunLoopDefaultMode), ^{ + JSC::VM& vm = m_globalObject.vm(); + JSC::JSLockHolder lock(vm); + + JSC::JSValue liveSyncCallback = m_globalObject.get(m_globalObject.globalExec(), JSC::Identifier::fromString(&vm, "__onLiveSync")); + JSC::CallData callData; + JSC::CallType callType = getCallData(vm, liveSyncCallback, callData); + if (callType == JSC::CallType::None) { + JSC::JSValue error = JSC::createError(m_globalObject.globalExec(), "global.__onLiveSync is not a function."); + m_globalObject.inspectorController().reportAPIException(m_globalObject.globalExec(), JSC::Exception::create(vm, error)); + return; + } + + WTF::NakedPtr exception; + JSC::MarkedArgumentBuffer liveSyncArguments; + call(m_globalObject.globalExec(), liveSyncCallback, callType, callData, JSC::jsUndefined(), liveSyncArguments, exception); + if (exception) { + m_globalObject.inspectorController().reportAPIException(m_globalObject.globalExec(), exception); + } + }); + CFRunLoopWakeUp(runloop); } void InspectorPageAgent::navigate(ErrorString&, const String& in_url) { From 573f42031aacad97c01a56178af00a3685fabaf7 Mon Sep 17 00:00:00 2001 From: Martin Bektchiev Date: Mon, 25 Mar 2019 17:26:05 +0200 Subject: [PATCH 2/3] fix(build): Sporadic failures on Jenkins Uncomment `xcodebuild` build command of TestRunner before running `xcodebuild archive` --- build/scripts/build-testrunner-application.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/scripts/build-testrunner-application.sh b/build/scripts/build-testrunner-application.sh index 57badce49..d4b9f59e6 100755 --- a/build/scripts/build-testrunner-application.sh +++ b/build/scripts/build-testrunner-application.sh @@ -19,14 +19,14 @@ cmake .. -G"Xcode" mkdir -p "$NATIVESCRIPT_XCODEPROJ/xcshareddata/xcschemes" cp "$WORKSPACE/build/TestRunner.xcscheme" "$NATIVESCRIPT_XCODEPROJ/xcshareddata/xcschemes/TestRunner.xcscheme" -# xcodebuild \ -# -configuration "$CONFIGURATION" \ -# -sdk "iphoneos" \ -# -scheme "TestRunner" \ -# ARCHS="armv7 arm64" \ -# ONLY_ACTIVE_ARCH="NO" \ -# -project $NATIVESCRIPT_XCODEPROJ \ -# -quiet \ +xcodebuild \ +-configuration "$CONFIGURATION" \ +-sdk "iphoneos" \ +-scheme "TestRunner" \ +ARCHS="armv7 arm64" \ +ONLY_ACTIVE_ARCH="NO" \ +-project $NATIVESCRIPT_XCODEPROJ \ +-quiet \ xcodebuild archive \ -archivePath "$WORKSPACE/cmake-build/tests/TestRunner/$CONFIGURATION-iphoneos/TestRunner.xcarchive" \ From 9f45f862067b392ae70b621e9367e55308d404ab Mon Sep 17 00:00:00 2001 From: Martin Bektchiev Date: Mon, 25 Mar 2019 18:02:00 +0200 Subject: [PATCH 3/3] fix(build): Test apps cannot be built with CMake 3.14 There's an issue with the linker paths to `libNativeScript.a`. Add `NativeScript` target as a target dependency and manually add the path to the library --- cmake/CreateNativeScriptApp.cmake | 4 +++- src/NativeScript/CMakeLists.txt | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/CreateNativeScriptApp.cmake b/cmake/CreateNativeScriptApp.cmake index 3ef0fe63d..84156cdec 100644 --- a/cmake/CreateNativeScriptApp.cmake +++ b/cmake/CreateNativeScriptApp.cmake @@ -13,11 +13,13 @@ function(CreateNativeScriptApp _target _main _plist _resources) ) if(NOT ${BUILD_SHARED_LIBS}) + add_dependencies(${_target} NativeScript) target_link_libraries(${_target} - NativeScript libicucore.dylib libz.dylib libc++.dylib + "-lNativeScript" + "-L${NativeScriptFramework_BINARY_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" ) if(NOT ${EMBED_STATIC_DEPENDENCIES}) diff --git a/src/NativeScript/CMakeLists.txt b/src/NativeScript/CMakeLists.txt index 60b500c2b..b401e77e6 100644 --- a/src/NativeScript/CMakeLists.txt +++ b/src/NativeScript/CMakeLists.txt @@ -229,7 +229,13 @@ set(JSFILES smartStringify.js ) -include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/**" "${LIBFFI_INCLUDE_DIR}" "${WEBKIT_INCLUDE_DIRECTORIES}") +include_directories( + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/**" + "${LIBFFI_INCLUDE_DIR}" + "${WEBKIT_INCLUDE_DIRECTORIES}" +) + link_directories("${LIBFFI_LIB_DIR}" ${WEBKIT_LINK_DIRECTORIES}) add_library(NativeScript ${SOURCE_FILES} ${HEADER_FILES} ${JSFILES})