diff --git a/ci/before_install.sh b/ci/before_install.sh index 9de65ca679..2b127c9f58 100755 --- a/ci/before_install.sh +++ b/ci/before_install.sh @@ -67,6 +67,8 @@ then lldb --help cmake --version man lldb + cat /System/Library/Frameworks/JavaScriptCore.framework/Resources/Info.plist + cat /System/Library/Frameworks/JavaScriptCore.framework/Resources/version.plist fi #install lighttpd, code coverage binaries for mac diff --git a/ci/build_linux.sh b/ci/build_linux.sh index 507737986e..1e52554902 100755 --- a/ci/build_linux.sh +++ b/ci/build_linux.sh @@ -27,7 +27,7 @@ export PKG_CONFIG_PATH=$TRAVIS_BUILD_DIR/examples/pxScene2d/external/extlibs/lib if [ "$TRAVIS_PULL_REQUEST" = "false" ] then echo "************************* Generating config files *************************" >> $BUILDLOGS - cmake -DPREFER_SYSTEM_LIBRARIES=ON -DPREFER_PKGCONFIG=ON -DPREFER_EXTERNAL_GIF=ON -DSPARK_ENABLE_VIDEO=ON -DBUILD_PX_TESTS=ON -DBUILD_PXSCENE_STATIC_LIB=ON -DBUILD_DEBUG_METRICS=ON -DPXSCENE_TEST_HTTP_CACHE=ON .. >>$BUILDLOGS 2>&1; + cmake -DSUPPORT_JSC=OFF -DPREFER_SYSTEM_LIBRARIES=ON -DPREFER_PKGCONFIG=ON -DPREFER_EXTERNAL_GIF=ON -DSPARK_ENABLE_VIDEO=ON -DBUILD_PX_TESTS=ON -DBUILD_PXSCENE_STATIC_LIB=ON -DBUILD_DEBUG_METRICS=ON -DPXSCENE_TEST_HTTP_CACHE=ON .. >>$BUILDLOGS 2>&1; checkError $? "cmake config failed" "Config error" "Check the error in $BUILDLOGS" echo "************************* Building pxcore,rtcore,pxscene app,libpxscene, unitttests ****" >> $BUILDLOGS @@ -36,7 +36,7 @@ then else echo "************************* Generating config files ****" - cmake -DPREFER_SYSTEM_LIBRARIES=ON -DPREFER_PKGCONFIG=ON -DPREFER_EXTERNAL_GIF=ON -DSPARK_ENABLE_VIDEO=ON -DBUILD_PX_TESTS=ON -DBUILD_PXSCENE_STATIC_LIB=ON -DBUILD_DEBUG_METRICS=ON -DPXSCENE_TEST_HTTP_CACHE=ON .. 1>>$BUILDLOGS; + cmake -DSUPPORT_JSC=OFF -DPREFER_SYSTEM_LIBRARIES=ON -DPREFER_PKGCONFIG=ON -DPREFER_EXTERNAL_GIF=ON -DSPARK_ENABLE_VIDEO=ON -DBUILD_PX_TESTS=ON -DBUILD_PXSCENE_STATIC_LIB=ON -DBUILD_DEBUG_METRICS=ON -DPXSCENE_TEST_HTTP_CACHE=ON .. 1>>$BUILDLOGS; checkError $? "cmake config failed" "Config error" "Check the errors displayed in this window" echo "************************* Building pxcore,rtcore,pxscene app,libpxscene, unitttests ********" diff --git a/ci/execute_osx.sh b/ci/execute_osx.sh index df86c67ec3..2bb36f4d3c 100755 --- a/ci/execute_osx.sh +++ b/ci/execute_osx.sh @@ -57,6 +57,13 @@ printExecLogs() # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Start testRunner ... +sparkPlatform=$1 +if [ "$sparkPlatform" = "jsc" ]; then +export SPARK_USE_JSC=1 + echo "Running under JSC Platform" +else + echo "Running under Node Platform" +fi rm -rf /var/tmp/spark.log cd $TRAVIS_BUILD_DIR/examples/pxScene2d/src/spark.app/Contents/MacOS ./spark.sh -enableVideo=false $TESTRUNNERURL?tests=$TESTS & @@ -155,6 +162,7 @@ fi echo "Sleeping to make terminate complete ..."; sleep 90s pkill -9 -f spark.sh +pkill -9 -f Spark cp /var/tmp/spark.log $EXECLOGS if [ "$dumped_core" -eq 1 ] diff --git a/ci/script.sh b/ci/script.sh index 64f051fd0a..5018c2ebe1 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -73,9 +73,15 @@ then sh "unittests_$TRAVIS_OS_NAME.sh" checkError $? "#### Build/unittests/execution [unittests_$TRAVIS_OS_NAME.sh] failed" "Either build problem/execution problem" "Analyze corresponding log file" - sh "execute_$TRAVIS_OS_NAME.sh" - checkError $? "#### Build/unittests/execution [execute_$TRAVIS_OS_NAME.sh] failed" "Either build problem/execution problem" "Analyze corresponding log file" + if [ "$TRAVIS_OS_NAME" = "osx" ] + then + sh "execute_$TRAVIS_OS_NAME.sh" "jsc" + checkError $? "#### Build/unittests/execution jsc platform [execute_$TRAVIS_OS_NAME.sh] failed" "Either build problem/execution problem" "Analyze corresponding log file" + fi + sh "execute_$TRAVIS_OS_NAME.sh" "node" + checkError $? "#### Build/unittests/execution node platform [execute_$TRAVIS_OS_NAME.sh] failed" "Either build problem/execution problem" "Analyze corresponding log file" + sh "code_coverage_$TRAVIS_OS_NAME.sh" checkError $? "#### Build/unittests/execution [code_coverage_$TRAVIS_OS_NAME.sh] failed" "Either build problem/execution problem" "Analyze corresponding log file" diff --git a/examples/pxScene2d/src/pxResource.cpp b/examples/pxScene2d/src/pxResource.cpp index c6e0e3c77e..fe4212a939 100644 --- a/examples/pxScene2d/src/pxResource.cpp +++ b/examples/pxScene2d/src/pxResource.cpp @@ -398,7 +398,7 @@ void rtImageResource::textureReady() int32_t rtImageResource::w() const { //rtLogDebug("tImageResource::w()\n"); - if(mTexture.getPtr()) + if(!downloadInProgress() && mTexture.getPtr()) return mTexture->width(); else return 0; @@ -406,7 +406,7 @@ int32_t rtImageResource::w() const rtError rtImageResource::w(int32_t& v) const { //rtLogDebug("tImageResource::w(int32_t)\n"); - if(mTexture.getPtr()) + if(!downloadInProgress() && mTexture.getPtr()) v = mTexture->width(); else v = 0; diff --git a/examples/pxScene2d/src/rcvrcore/initGL.js b/examples/pxScene2d/src/rcvrcore/initGL.js index ec78aa0375..9f79594e78 100644 --- a/examples/pxScene2d/src/rcvrcore/initGL.js +++ b/examples/pxScene2d/src/rcvrcore/initGL.js @@ -297,9 +297,18 @@ function onSceneTerminate() { // memory leak fix this.sandbox.sparkscene.api = null; - for (var k in this.sandbox) - { - delete this.sandbox[k]; + if (isJSC) { + var script = new vm.Script( + "for (var key in this) { delete this[key]; }" + ); + script.runInContext(this.sandbox); + script = null; + } + else { + for (var k in this.sandbox) + { + delete this.sandbox[k]; + } } this.contextifiedSandbox = null; diff --git a/src/rtScriptJSC/rtJSCBindings.cpp b/src/rtScriptJSC/rtJSCBindings.cpp index a225389e3e..63d06c81f0 100644 --- a/src/rtScriptJSC/rtJSCBindings.cpp +++ b/src/rtScriptJSC/rtJSCBindings.cpp @@ -182,7 +182,7 @@ static JSValueRef requireCallback(JSContextRef ctx, JSObjectRef, JSObjectRef thi return moduleObj; } - rtLogInfo("Loading %s", path.cString()); + rtLogDebug("Loading %s", path.cString()); std::string codeStr = readFile(path.cString()); if (codeStr.empty()) { JSStringRelease(reqArgStr); diff --git a/src/rtScriptJSC/rtJSCWrappers.cpp b/src/rtScriptJSC/rtJSCWrappers.cpp index 91a5926b88..cde57ca372 100644 --- a/src/rtScriptJSC/rtJSCWrappers.cpp +++ b/src/rtScriptJSC/rtJSCWrappers.cpp @@ -271,12 +271,12 @@ static bool rtObjectWrapper_setProperty(JSContextRef context, JSObjectRef thisOb } rtValue val; + rtString name = jsToRtString(propertyName); if (jsToRt(context, value, val, exception) != RT_OK) { printException(context, *exception); return false; } - rtString name = jsToRtString(propertyName); rtError e = objectRef.set(name, val); if (e != RT_OK) { rtLogDebug("Failed to set property: %s", name.cString()); @@ -351,7 +351,6 @@ static bool rtObjectWrapper_hasProperty(JSContextRef ctx, JSObjectRef object, JS { rtMethodMap* objMap = objectRef->getMap(); const char* className = objMap ? objMap->className : ""; - printf("rtObjectWrapper_hasProperty class=%s prop=%s\n", className, propName.cString()); } if ( !strcmp(propName.cString(), "Symbol.iterator") || @@ -973,6 +972,11 @@ rtError JSObjectWrapper::Get(uint32_t i, rtValue* value) const return RT_ERROR_INVALID_ARG; JSValueRef exc = nullptr; JSValueRef valueRef = JSObjectGetPropertyAtIndex(context(), wrapped(), i, &exc); + + if (JSValueGetType(context(), valueRef) == kJSTypeUndefined) + { + return RT_PROPERTY_NOT_FOUND; + } if (exc) { printException(context(), exc); return RT_FAIL; @@ -993,7 +997,8 @@ rtError JSObjectWrapper::Set(const char* name, const rtValue* value) return RT_FAIL; } if (!name || !value) - return RT_FAIL; + return RT_ERROR_INVALID_ARG; + if (m_isArray) return RT_PROP_NOT_FOUND; JSValueRef valueRef = rtToJs(context(), *value); @@ -1012,7 +1017,7 @@ rtError JSObjectWrapper::Set(uint32_t i, const rtValue* value) { RtJSC::assertIsMainThread(); if (!value) - return RT_FAIL; + return RT_ERROR_INVALID_ARG; JSValueRef valueRef = rtToJs(context(), *value); JSValueRef exc = nullptr; JSObjectSetPropertyAtIndex(context(), wrapped(), i, valueRef, &exc); diff --git a/src/rtScriptJSC/rtScriptJSC.cpp b/src/rtScriptJSC/rtScriptJSC.cpp index 705fae442c..1dc13a3f66 100644 --- a/src/rtScriptJSC/rtScriptJSC.cpp +++ b/src/rtScriptJSC/rtScriptJSC.cpp @@ -267,7 +267,7 @@ class rtJSCContext: public RefCounted rtJSCContext::rtJSCContext() { - rtLogInfo("%s", __FUNCTION__); + rtLogInfo("%s %p\n", __FUNCTION__, this); m_contextGroup = JSContextGroupRetain(globalContextGroup()); m_context = JSGlobalContextCreateInGroup(m_contextGroup, nullptr); m_priv = rtJSCContextPrivate::create(m_context); @@ -294,11 +294,16 @@ rtJSCContext::rtJSCContext() rtJSCContext::~rtJSCContext() { - rtLogInfo("%s begin", __FUNCTION__); + rtLogInfo("%s %p begin", __FUNCTION__, this); if (gTopLevelContext == m_context) + { + if (gTopLevelContext != nullptr) { + JSSynchronousGarbageCollectForDebugging(gTopLevelContext); + } gTopLevelContext = nullptr; - + } + // RtJSC::dispatchOnMainLoop([m_priv=m_priv,m_context=m_context,m_contextGroup=m_contextGroup] { // static JSStringRef codeStr = JSStringCreateWithUTF8CString("console.clear(); delete global.console"); // JSEvaluateScript(m_context, codeStr, nullptr, nullptr, 0, nullptr); @@ -476,8 +481,7 @@ rtError rtScriptJSC::pump() rtError rtScriptJSC::collectGarbage() { if (gTopLevelContext) { - JSGarbageCollect(gTopLevelContext); - // JSSynchronousGarbageCollectForDebugging(gTopLevelContext); + JSSynchronousGarbageCollectForDebugging(gTopLevelContext); } return RT_OK; } diff --git a/tests/pxScene2d/pxscene2dtests.sh b/tests/pxScene2d/pxscene2dtests.sh index 55f6872064..ad4b8b8318 100755 --- a/tests/pxScene2d/pxscene2dtests.sh +++ b/tests/pxScene2d/pxscene2dtests.sh @@ -53,6 +53,8 @@ export SPARK_PERMISSIONS_ENABLED=true ln -s ../../examples/pxScene2d/src/shell.js shell.js ln -s ../../examples/pxScene2d/src/init.js init.js ln -s ../../examples/pxScene2d/src/node_modules/ node_modules +ln -s ../../examples/pxScene2d/src/jsc_modules/ jsc_modules +ln -s ../../examples/pxScene2d/src/v8_modules/ v8_modules ln -s ../../examples/pxScene2d/src/rcvrcore/ rcvrcore ln -s ../../examples/pxScene2d/src/FreeSans.ttf FreeSans.ttf ln -s ../../examples/pxScene2d/src/package.json package.json @@ -66,6 +68,8 @@ ${DBG} ./pxscene2dtests "$@" rm -rf shell.js rm -rf init.js rm -rf node_modules +rm -rf jsc_modules +rm -rf v8_modules rm -rf rcvrcore rm -rf FreeSans.ttf rm -rf package.json diff --git a/tests/pxScene2d/test_memoryleak.cpp b/tests/pxScene2d/test_memoryleak.cpp index 462b69a52c..4a2be1f18d 100644 --- a/tests/pxScene2d/test_memoryleak.cpp +++ b/tests/pxScene2d/test_memoryleak.cpp @@ -114,6 +114,7 @@ class pxSceneContainerLeakTest : public testing::Test sceneContainer->AddRef(); sceneContainer->remove(); script.collectGarbage(); + process(); EXPECT_TRUE (sceneptr->isObjectTracked(sceneContainer) == false); sceneContainer->Release(); } diff --git a/tests/pxScene2d/test_rtnode.cpp b/tests/pxScene2d/test_rtnode.cpp index 32bfbcb1f9..7b98c1a0a8 100644 --- a/tests/pxScene2d/test_rtnode.cpp +++ b/tests/pxScene2d/test_rtnode.cpp @@ -31,7 +31,7 @@ TEST(pxScene2dTests, rtNodeTests) { // Create rtNode extern rtScript script; - + if (script.engine().compare("node/v8") == 0) { //v8::Isolate *isolate = script.getIsolate(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -210,4 +210,8 @@ TEST(pxScene2dTests, rtNodeTests) EXPECT_TRUE((t2 < (t1 / 4)) == true); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + } + else { + EXPECT_TRUE(true); + } }