From 75b99e71ecbce70218e433efc4d4dcee02b7e919 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 11 Aug 2020 15:49:34 -0700 Subject: [PATCH 01/28] playing with gha --- .github/workflows/pr_build.yml | 51 ++++++++++++++++++++++++++++++---- android/build_android.sh | 10 +++---- android/containerized_build.sh | 8 +++--- android/docker/Dockerfile | 28 ++++++++----------- prebuild.py | 2 +- 5 files changed, 66 insertions(+), 33 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index f28cf1e66b..7bd061e7d2 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -27,14 +27,20 @@ env: jobs: build: + name: "build (${{matrix.os}}, ${{matrix.build_type}})" strategy: matrix: - os: [windows-latest, macOS-latest, ubuntu-18.04] - build_type: [full] include: + - os: windows-latest + build_type: full + - os: macOS-latest + build_type: full - os: ubuntu-18.04 build_type: full apt-dependencies: mesa-common-dev libegl1 libglvnd-dev libdouble-conversion1 libpulse0 + - os: ubuntu-18.04 + build_type: android + apt-dependencies: mesa-common-dev libegl1 libglvnd-dev libdouble-conversion1 libpulse0 fail-fast: false runs-on: ${{matrix.os}} if: github.event.action != 'labeled' || github.event.label.name == 'rebuild' @@ -65,14 +71,25 @@ jobs: echo ::set-env name=INSTALLER_EXT::exe echo ::set-env name=CMAKE_EXTRA::"-A x64" fi + # Android + Quest build variables + if [[ "${{ matrix.build_type }}" == "android" ]]; then + HIFI_ANDROID_PRECOMPILED="${{runner.workspace}}/dependencies" + echo ::set-env name=HIFI_ANDROID_PRECOMPILED::"$HIFI_ANDROID_PRECOMPILED" + mkdir $HIFI_ANDROID_PRECOMPILED + echo ::set-env name=INSTALLER_EXT::apk + fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure Build Environment 2 shell: bash run: | echo "${{ steps.buildenv1.outputs.symbols_archive }}" - echo ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT - # Build type variables - echo ::set-env name=INSTALLER::Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + if [[ "${{ matrix.build_type }}" != "android" ]]; then + echo ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT + # Build type variables + echo ::set-env name=INSTALLER::Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + else + echo ::set-env name=ARTIFACT_PATTERN::*.$INSTALLER_EXT + fi - name: Clear Working Directory if: startsWith(matrix.os, 'windows') shell: bash @@ -98,26 +115,32 @@ jobs: shell: bash run: cmake -E make_directory "${{runner.workspace}}/build" - name: Configure CMake + if: matrix.build_type != 'android' working-directory: ${{runner.workspace}}/build shell: bash run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_BUILD_TYPE=release $CMAKE_EXTRA - name: Build Application + if: matrix.build_type == 'full' || matrix.build_type == 'client' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target $APP_NAME $CMAKE_BUILD_EXTRA - name: Build Domain Server + if: matrix.build_type == 'full' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target domain-server $CMAKE_BUILD_EXTRA - name: Build Assignment Client + if: matrix.build_type == 'full' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target assignment-client $CMAKE_BUILD_EXTRA - name: Build Console + if: matrix.build_type == 'full' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target packaged-server-console $CMAKE_BUILD_EXTRA - name: Build Installer + if: matrix.build_type != 'android' working-directory: ${{runner.workspace}}/build shell: bash run: | @@ -144,6 +167,18 @@ jobs: done } retry cmake --build . --config $BUILD_TYPE --target package $CMAKE_BUILD_EXTRA + - name: Build for Android + Quest + if: matrix.build_type == 'android' + shell: bash + working-directory: ${{runner.workspace}}/project-athena + run: | + echo "Pre-cache the vcpkg managed dependencies" + $PYTHON_EXEC prebuild.py --build-root ${{runner.workspace}}/build --android interface + cd android + # Pre-cache the gradle dependencies + ./gradlew -m tasks -PHIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED + # Build! + ./build_android.sh - name: Output system stats if: ${{ always() }} working-directory: ${{runner.workspace}}/build @@ -161,4 +196,8 @@ jobs: working-directory: ${{runner.workspace}}/build env: GITHUB_CONTEXT: ${{ toJson(github) }} - run: $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py" + run: | + if [[ "${{ matrix.build_type }}" == "android" ]]; then + cd $GITHUB_WORKSPACE/android + fi + $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py" \ No newline at end of file diff --git a/android/build_android.sh b/android/build_android.sh index e9c69b09de..9cf1b9e2ab 100755 --- a/android/build_android.sh +++ b/android/build_android.sh @@ -5,11 +5,11 @@ ANDROID_BUILD_TYPE=release ANDROID_BUILD_TARGET=assembleRelease if [[ "$RELEASE_TYPE" == "PR" ]]; then -ANDROID_APK_SUFFIX=PR${RELEASE_NUMBER}-${SHA7}.apk ; +ANDROID_APK_SUFFIX=PR${RELEASE_NUMBER}-${GIT_COMMIT_SHORT}.apk ; elif [[ "${STABLE_BUILD}" == "1" ]]; then ANDROID_APK_SUFFIX=${RELEASE_NUMBER}.apk ; else -ANDROID_APK_SUFFIX=${RELEASE_NUMBER}-${SHA7}.apk ; +ANDROID_APK_SUFFIX=${RELEASE_NUMBER}-${GIT_COMMIT_SHORT}.apk ; fi @@ -17,7 +17,7 @@ fi ANDROID_APP=interface ANDROID_OUTPUT_DIR=./apps/${ANDROID_APP}/build/outputs/apk/${ANDROID_BUILD_TYPE} ANDROID_OUTPUT_FILE=${ANDROID_APP}-${ANDROID_BUILD_TYPE}.apk -ANDROID_APK_NAME=HighFidelity-Beta-${ANDROID_APK_SUFFIX} +ANDROID_APK_NAME=Vircadia-Alpha-${ANDROID_APK_SUFFIX} ./gradlew -PHIFI_ANDROID_PRECOMPILED=${HIFI_ANDROID_PRECOMPILED} -PVERSION_CODE=${VERSION_CODE} -PRELEASE_NUMBER=${RELEASE_NUMBER} -PRELEASE_TYPE=${RELEASE_TYPE} ${ANDROID_APP}:${ANDROID_BUILD_TARGET} cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} @@ -25,9 +25,9 @@ cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} ANDROID_APP=questInterface ANDROID_OUTPUT_DIR=./apps/${ANDROID_APP}/build/outputs/apk/${ANDROID_BUILD_TYPE} ANDROID_OUTPUT_FILE=${ANDROID_APP}-${ANDROID_BUILD_TYPE}.apk -ANDROID_APK_NAME=HighFidelity-Quest-Beta-${ANDROID_APK_SUFFIX} +ANDROID_APK_NAME=Vircadia-Quest-Alpha-${ANDROID_APK_SUFFIX} ./gradlew -PHIFI_ANDROID_PRECOMPILED=${HIFI_ANDROID_PRECOMPILED} -PVERSION_CODE=${VERSION_CODE} -PRELEASE_NUMBER=${RELEASE_NUMBER} -PRELEASE_TYPE=${RELEASE_TYPE} ${ANDROID_APP}:${ANDROID_BUILD_TARGET} || true -cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} || true +cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} diff --git a/android/containerized_build.sh b/android/containerized_build.sh index 0c21d1df91..94b5b28831 100755 --- a/android/containerized_build.sh +++ b/android/containerized_build.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -xeuo pipefail -DOCKER_IMAGE_NAME="hifi_androidbuild" +DOCKER_IMAGE_NAME="vircadia_androidbuild" -docker build --build-arg BUILD_UID=`id -u` -t "${DOCKER_IMAGE_NAME}" -f docker/Dockerfile docker +docker build --build-arg BUILD_UID=`id -u` -t "${DOCKER_IMAGE_NAME}" -f ./android/docker/Dockerfile ./android/docker # The Jenkins PR builds use VERSION_CODE, but the release builds use VERSION # So make sure we use VERSION_CODE consistently @@ -17,7 +17,7 @@ test -z "$STABLE_BUILD" && export STABLE_BUILD=0 docker run \ --rm \ --security-opt seccomp:unconfined \ - -v "${WORKSPACE}":/home/jenkins/hifi \ + -v "${WORKSPACE}":/home/gha/project-athena \ -e RELEASE_NUMBER \ -e RELEASE_TYPE \ -e ANDROID_APP \ @@ -33,7 +33,7 @@ docker run \ -e OAUTH_CLIENT_SECRET \ -e OAUTH_CLIENT_ID \ -e OAUTH_REDIRECT_URI \ - -e SHA7 \ + -e GIT_COMMIT_SHORT \ -e STABLE_BUILD \ -e VERSION_CODE \ "${DOCKER_IMAGE_NAME}" \ diff --git a/android/docker/Dockerfile b/android/docker/Dockerfile index f6c0e7b2e5..144f6caffa 100644 --- a/android/docker/Dockerfile +++ b/android/docker/Dockerfile @@ -57,13 +57,13 @@ RUN apt-get -y install \ # --- Gradle ARG BUILD_UID=1001 -RUN useradd -ms /bin/bash -u $BUILD_UID jenkins -RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -USER jenkins -WORKDIR /home/jenkins +RUN useradd -ms /bin/bash -u $BUILD_UID gha +RUN echo "gha ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +USER gha +WORKDIR /home/gha -# Hifi dependencies -ENV HIFI_BASE="/home/jenkins/hifi_android" +# Vircadia dependencies +ENV HIFI_BASE="/home/gha/vircadia_android" ENV HIFI_ANDROID_PRECOMPILED="$HIFI_BASE/dependencies" ENV HIFI_VCPKG_BASE="$HIFI_BASE/vcpkg" @@ -71,24 +71,18 @@ RUN mkdir "$HIFI_BASE" && \ mkdir "$HIFI_VCPKG_BASE" && \ mkdir "$HIFI_ANDROID_PRECOMPILED" -# Checkout a relatively recent commit from the main repository and use it to cache the -# gradle and vcpkg dependencies -# This commit ID should be updated whenever someone changes the dependency list -# in cmake/ports -RUN git clone https://github.com/highfidelity/hifi.git && \ - cd ~/hifi && \ - git checkout 796bfb5d6715ff14c2e60f3ee8fac1465b7578c6 +# Download the repo +RUN git clone https://github.com/kasenvr/project-athena.git -WORKDIR /home/jenkins/hifi +WORKDIR /home/gha/project-athena RUN mkdir build # Pre-cache the vcpkg managed dependencies -WORKDIR /home/jenkins/hifi/build +WORKDIR /home/gha/project-athena/build RUN python3 ../prebuild.py --build-root `pwd` --android interface # Pre-cache the gradle dependencies -WORKDIR /home/jenkins/hifi/android +WORKDIR /home/gha/project-athena/android RUN ./gradlew -m tasks -PHIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED #RUN ./gradlew extractDependencies -PHIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED - diff --git a/prebuild.py b/prebuild.py index cc315a49a4..21363bb9de 100644 --- a/prebuild.py +++ b/prebuild.py @@ -102,7 +102,7 @@ def parse_args(): if True: args = parser.parse_args() else: - args = parser.parse_args(['--android', 'questInterface', '--build-root', 'C:/git/hifi/android/apps/questInterface/.externalNativeBuild/cmake/debug/arm64-v8a']) + args = parser.parse_args(['--android', 'questInterface', '--build-root', 'C:/git/project-athena/android/apps/questInterface/.externalNativeBuild/cmake/debug/arm64-v8a']) return args def main(): From 91a35fb4bae944e6eaeac4a4ad2ba5aee0904d5f Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Wed, 19 Aug 2020 16:47:04 -0700 Subject: [PATCH 02/28] change quick goto --- .github/workflows/pr_build.yml | 1 - scripts/system/quickGoto.js | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 7bd061e7d2..3c6b91c65b 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -115,7 +115,6 @@ jobs: shell: bash run: cmake -E make_directory "${{runner.workspace}}/build" - name: Configure CMake - if: matrix.build_type != 'android' working-directory: ${{runner.workspace}}/build shell: bash run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_BUILD_TYPE=release $CMAKE_EXTRA diff --git a/scripts/system/quickGoto.js b/scripts/system/quickGoto.js index c5560cce83..ec278dd1d2 100644 --- a/scripts/system/quickGoto.js +++ b/scripts/system/quickGoto.js @@ -30,7 +30,8 @@ }); } - addGotoButton("dev-mobile"); - addGotoButton("quest-dev"); + addGotoButton("172.104.248.237"); + addGotoButton("167.172.61.134"); + addGotoButton("file:///~/serverless/tutorial.json"); }()); // END LOCAL_SCOPE From cec0b41042581d9c625690a255a4d08a4c13eb40 Mon Sep 17 00:00:00 2001 From: HifiExperiments <53453710+HifiExperiments@users.noreply.github.com> Date: Fri, 30 Oct 2020 16:41:59 -0700 Subject: [PATCH 03/28] Apply suggestions from code review Co-authored-by: kasenvr <52365539+kasenvr@users.noreply.github.com> --- scripts/system/quickGoto.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/quickGoto.js b/scripts/system/quickGoto.js index ec278dd1d2..3211688e6e 100644 --- a/scripts/system/quickGoto.js +++ b/scripts/system/quickGoto.js @@ -30,8 +30,8 @@ }); } - addGotoButton("172.104.248.237"); - addGotoButton("167.172.61.134"); + addGotoButton("hub.daleglass.net"); + addGotoButton("lq-hub.vircadia.com"); addGotoButton("file:///~/serverless/tutorial.json"); }()); // END LOCAL_SCOPE From 696239a97b3a92abc99b1823585d1b42259dddb5 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 9 Nov 2020 19:22:53 -0800 Subject: [PATCH 04/28] try to fix android build --- libraries/gl/src/gl/Config.cpp | 4 ++-- libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/gl/src/gl/Config.cpp b/libraries/gl/src/gl/Config.cpp index ab1dfac97c..2d6e3db8d2 100644 --- a/libraries/gl/src/gl/Config.cpp +++ b/libraries/gl/src/gl/Config.cpp @@ -96,7 +96,7 @@ void gl::initModuleGl() { wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)getGlProcessAddress("wglCreateContextAttribsARB"); #endif -#if defined(Q_OS_LINUX) +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) QueryCurrentRendererIntegerMESA = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)getGlProcessAddress("glXQueryCurrentRendererIntegerMESA"); #endif @@ -134,7 +134,7 @@ void gl::setSwapInterval(int interval) { } bool gl::queryCurrentRendererIntegerMESA(int attr, unsigned int *value) { - #if defined(Q_OS_LINUX) + #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) if (QueryCurrentRendererIntegerMESA) { return QueryCurrentRendererIntegerMESA(attr, value); } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index 602ab1c320..ef247b0835 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -153,9 +153,11 @@ void GLBackend::init() { if (vendor.contains("NVIDIA") ) { qCDebug(gpugllogging) << "NVIDIA card detected"; +#if !defined(Q_OS_ANDROID) GL_GET_INTEGER(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX); GL_GET_INTEGER(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX); GL_GET_INTEGER(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX); +#endif qCDebug(gpugllogging) << "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: " << GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX; qCDebug(gpugllogging) << "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: " << GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX; @@ -168,7 +170,9 @@ void GLBackend::init() { } else if (vendor.contains("ATI")) { qCDebug(gpugllogging) << "ATI card detected"; +#if !defined(Q_OS_ANDROID) GL_GET_INTEGER(TEXTURE_FREE_MEMORY_ATI); +#endif _totalMemory = TEXTURE_FREE_MEMORY_ATI * BYTES_PER_KIB; _dedicatedMemory = _totalMemory; @@ -219,10 +223,14 @@ size_t GLBackend::getAvailableMemory() { switch( _videoCard ) { case NVIDIA: +#if !defined(Q_OS_ANDROID) glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem); +#endif return mem * BYTES_PER_KIB; case ATI: +#if !defined(Q_OS_ANDROID) glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem); +#endif return mem * BYTES_PER_KIB; case MESA: return 0; // Don't know the current value From 2194a20d347bdb1d7a6b9135a74fa74a25eccb05 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 14 Nov 2020 18:55:24 +0100 Subject: [PATCH 05/28] Upgrade to latest TBB --- cmake/ports/tbb/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ports/tbb/portfile.cmake b/cmake/ports/tbb/portfile.cmake index 4e81df37d1..2e2e78abde 100644 --- a/cmake/ports/tbb/portfile.cmake +++ b/cmake/ports/tbb/portfile.cmake @@ -3,7 +3,7 @@ include(vcpkg_common_functions) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO oneapi-src/oneTBB - REF 4bdba61bafc6ba2d636f31564f1de5702d365cf7 + REF eca91f16d7490a8abfdee652dadf457ec820cc37 SHA512 f2a8d7e0476f846039390f4a79af3fe13770e23b01bf4741e738136f7ddb401357a0e50f35212e8d0fa5fc4cf1563418337309227d7243fc3676edd406ae652d HEAD_REF tbb_2019 PATCHES fix-static-build.patch From 8e2245c530293b5aaf6fc1ef2583fde1519edc5c Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 14 Nov 2020 19:00:53 +0100 Subject: [PATCH 06/28] Update hash --- cmake/ports/tbb/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ports/tbb/portfile.cmake b/cmake/ports/tbb/portfile.cmake index 2e2e78abde..76c881833f 100644 --- a/cmake/ports/tbb/portfile.cmake +++ b/cmake/ports/tbb/portfile.cmake @@ -4,7 +4,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO oneapi-src/oneTBB REF eca91f16d7490a8abfdee652dadf457ec820cc37 - SHA512 f2a8d7e0476f846039390f4a79af3fe13770e23b01bf4741e738136f7ddb401357a0e50f35212e8d0fa5fc4cf1563418337309227d7243fc3676edd406ae652d + SHA512 7144e1dc68304b5358e6ea330431b6f0c61fadb147efa353a5b242777d6fabf7b8cf99b79cffb51b49b911dd17a9f1879619d6eebdf319f23ec3235c89cffc25 HEAD_REF tbb_2019 PATCHES fix-static-build.patch ) From 21f8eac9362ad36e151ab8b24f1b5f59807ebddc Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Mon, 16 Nov 2020 22:35:46 -0500 Subject: [PATCH 07/28] Revert "Split Local and owned Avatar Entity scripts into their own ScriptEngine" --- .../src/scripts/EntityScriptServer.cpp | 4 +- .../src/EntityTreeRenderer.cpp | 230 +++++++----------- .../src/EntityTreeRenderer.h | 9 +- .../entities/src/EntityScriptingInterface.cpp | 34 +-- .../entities/src/EntityScriptingInterface.h | 15 +- 5 files changed, 109 insertions(+), 183 deletions(-) diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index 16931e8c26..065ab12abc 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -470,9 +470,7 @@ void EntityScriptServer::resetEntitiesScriptEngine() { scriptEngines->runScriptInitializers(newEngine); newEngine->runInThread(); auto newEngineSP = qSharedPointerCast(newEngine); - // On the entity script server, these are the same - DependencyManager::get()->setPersistentEntitiesScriptEngine(newEngineSP); - DependencyManager::get()->setNonPersistentEntitiesScriptEngine(newEngineSP); + DependencyManager::get()->setEntitiesScriptEngine(newEngineSP); if (_entitiesScriptEngine) { disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 2f9c8c4b3a..3538f07d32 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -158,98 +158,79 @@ render::ItemID EntityTreeRenderer::renderableIdForEntityId(const EntityItemID& i int EntityTreeRenderer::_entitiesScriptEngineCount = 0; -void EntityTreeRenderer::setupEntityScriptEngineSignals(const ScriptEnginePointer& scriptEngine) { +void EntityTreeRenderer::resetEntitiesScriptEngine() { + _entitiesScriptEngine = scriptEngineFactory(ScriptEngine::ENTITY_CLIENT_SCRIPT, NO_SCRIPT, + QString("about:Entities %1").arg(++_entitiesScriptEngineCount)); + DependencyManager::get()->runScriptInitializers(_entitiesScriptEngine); + _entitiesScriptEngine->runInThread(); + auto entitiesScriptEngineProvider = qSharedPointerCast(_entitiesScriptEngine); auto entityScriptingInterface = DependencyManager::get(); + entityScriptingInterface->setEntitiesScriptEngine(entitiesScriptEngineProvider); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mousePressOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "mousePressOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseDoublePressOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "mouseDoublePressOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseMoveOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "mouseMoveOnEntity", event); - // FIXME: this is a duplicate of mouseMoveOnEntity, but it seems like some scripts might use this naming - scriptEngine->callEntityScriptMethod(entityID, "mouseMoveEvent", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseReleaseOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "mouseReleaseOnEntity", event); - }); - - connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "clickDownOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::holdingClickOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "holdingClickOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickReleaseOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "clickReleaseOnEntity", event); - }); - - connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverEnterEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "hoverEnterEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverOverEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "hoverOverEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - scriptEngine->callEntityScriptMethod(entityID, "hoverLeaveEntity", event); - }); - - connect(scriptEngine.data(), &ScriptEngine::entityScriptPreloadFinished, [&](const EntityItemID& entityID) { + connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptPreloadFinished, [&](const EntityItemID& entityID) { EntityItemPointer entity = getTree()->findEntityByID(entityID); if (entity) { entity->setScriptHasFinishedPreload(true); } }); -} -void EntityTreeRenderer::resetPersistentEntitiesScriptEngine() { - if (_persistentEntitiesScriptEngine) { - _persistentEntitiesScriptEngine->unloadAllEntityScripts(true); - _persistentEntitiesScriptEngine->stop(); - _persistentEntitiesScriptEngine->waitTillDoneRunning(); - _persistentEntitiesScriptEngine->disconnectNonEssentialSignals(); + // Connect mouse events to entity script callbacks + if (!_mouseAndPreloadSignalHandlersConnected) { + + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mousePressOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "mousePressOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseDoublePressOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseDoublePressOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseMoveOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseMoveOnEntity", event); + // FIXME: this is a duplicate of mouseMoveOnEntity, but it seems like some scripts might use this naming + _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseMoveEvent", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseReleaseOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseReleaseOnEntity", event); + }); + + connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "clickDownOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::holdingClickOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "holdingClickOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickReleaseOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "clickReleaseOnEntity", event); + }); + + connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverEnterEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverEnterEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverOverEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverOverEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverLeaveEntity", event); + }); + + _mouseAndPreloadSignalHandlersConnected = true; } - _persistentEntitiesScriptEngine = scriptEngineFactory(ScriptEngine::ENTITY_CLIENT_SCRIPT, NO_SCRIPT, - QString("about:Entities %1").arg(++_entitiesScriptEngineCount)); - DependencyManager::get()->runScriptInitializers(_persistentEntitiesScriptEngine); - _persistentEntitiesScriptEngine->runInThread(); - auto entitiesScriptEngineProvider = qSharedPointerCast(_persistentEntitiesScriptEngine); - auto entityScriptingInterface = DependencyManager::get(); - entityScriptingInterface->setPersistentEntitiesScriptEngine(entitiesScriptEngineProvider); - - setupEntityScriptEngineSignals(_persistentEntitiesScriptEngine); -} - -void EntityTreeRenderer::resetNonPersistentEntitiesScriptEngine() { - if (_nonPersistentEntitiesScriptEngine) { - _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(false); - _nonPersistentEntitiesScriptEngine->stop(); - _nonPersistentEntitiesScriptEngine->waitTillDoneRunning(); - _nonPersistentEntitiesScriptEngine->disconnectNonEssentialSignals(); - } - _nonPersistentEntitiesScriptEngine = scriptEngineFactory(ScriptEngine::ENTITY_CLIENT_SCRIPT, NO_SCRIPT, - QString("about:Entities %1").arg(++_entitiesScriptEngineCount)); - DependencyManager::get()->runScriptInitializers(_nonPersistentEntitiesScriptEngine); - _nonPersistentEntitiesScriptEngine->runInThread(); - auto entitiesScriptEngineProvider = qSharedPointerCast(_nonPersistentEntitiesScriptEngine); - DependencyManager::get()->setNonPersistentEntitiesScriptEngine(entitiesScriptEngineProvider); - - setupEntityScriptEngineSignals(_nonPersistentEntitiesScriptEngine); } void EntityTreeRenderer::stopDomainAndNonOwnedEntities() { leaveDomainAndNonOwnedEntities(); // unload and stop the engine - if (_nonPersistentEntitiesScriptEngine) { - QList entitiesWithEntityScripts = _nonPersistentEntitiesScriptEngine->getListOfEntityScriptIDs(); + if (_entitiesScriptEngine) { + QList entitiesWithEntityScripts = _entitiesScriptEngine->getListOfEntityScriptIDs(); - foreach (const EntityItemID& entityID, entitiesWithEntityScripts) { + foreach (const EntityItemID& entityID, entitiesWithEntityScripts) { EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID); + if (entityItem && !entityItem->getScript().isEmpty()) { if (!(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) { - _nonPersistentEntitiesScriptEngine->unloadEntityScript(entityID, true); + if (_currentEntitiesInside.contains(entityID)) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + } + _entitiesScriptEngine->unloadEntityScript(entityID, true); } } } @@ -259,10 +240,6 @@ void EntityTreeRenderer::stopDomainAndNonOwnedEntities() { void EntityTreeRenderer::clearDomainAndNonOwnedEntities() { stopDomainAndNonOwnedEntities(); - if (!_shuttingDown && _wantScripts) { - resetNonPersistentEntitiesScriptEngine(); - } - std::unordered_map savedEntities; std::unordered_set savedRenderables; // remove all entities from the scene @@ -292,22 +269,16 @@ void EntityTreeRenderer::clearDomainAndNonOwnedEntities() { void EntityTreeRenderer::clear() { leaveAllEntities(); + // unload and stop the engine + if (_entitiesScriptEngine) { + // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread + _entitiesScriptEngine->unloadAllEntityScripts(true); + _entitiesScriptEngine->stop(); + } // reset the engine auto scene = _viewState->getMain3DScene(); if (_shuttingDown) { - // unload and stop the engines - if (_nonPersistentEntitiesScriptEngine) { - // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread - _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(true); - _nonPersistentEntitiesScriptEngine->stop(); - } - if (_persistentEntitiesScriptEngine) { - // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread - _persistentEntitiesScriptEngine->unloadAllEntityScripts(true); - _persistentEntitiesScriptEngine->stop(); - } - if (scene) { render::Transaction transaction; for (const auto& entry : _entitiesInScene) { @@ -318,8 +289,7 @@ void EntityTreeRenderer::clear() { } } else { if (_wantScripts) { - resetPersistentEntitiesScriptEngine(); - resetNonPersistentEntitiesScriptEngine(); + resetEntitiesScriptEngine(); } if (scene) { for (const auto& entry : _entitiesInScene) { @@ -343,17 +313,13 @@ void EntityTreeRenderer::clear() { } void EntityTreeRenderer::reloadEntityScripts() { - _persistentEntitiesScriptEngine->unloadAllEntityScripts(); - _persistentEntitiesScriptEngine->resetModuleCache(); - _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(); - _nonPersistentEntitiesScriptEngine->resetModuleCache(); - + _entitiesScriptEngine->unloadAllEntityScripts(); + _entitiesScriptEngine->resetModuleCache(); for (const auto& entry : _entitiesInScene) { const auto& renderer = entry.second; const auto& entity = renderer->getEntity(); - if (entity && !entity->getScript().isEmpty()) { - auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - scriptEngine->loadEntityScript(entity->getEntityItemID(), resolveScriptURL(entity->getScript()), true); + if (!entity->getScript().isEmpty()) { + _entitiesScriptEngine->loadEntityScript(entity->getEntityItemID(), resolveScriptURL(entity->getScript()), true); } } } @@ -363,8 +329,7 @@ void EntityTreeRenderer::init() { EntityTreePointer entityTree = std::static_pointer_cast(_tree); if (_wantScripts) { - resetPersistentEntitiesScriptEngine(); - resetNonPersistentEntitiesScriptEngine(); + resetEntitiesScriptEngine(); } forceRecheckEntities(); // setup our state to force checking our inside/outsideness of entities @@ -376,11 +341,8 @@ void EntityTreeRenderer::init() { } void EntityTreeRenderer::shutdown() { - if (_persistentEntitiesScriptEngine) { - _persistentEntitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential - } - if (_nonPersistentEntitiesScriptEngine) { - _nonPersistentEntitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential + if (_entitiesScriptEngine) { + _entitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential } _shuttingDown = true; @@ -696,16 +658,12 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { // EntityItemIDs from here. The callEntityScriptMethod() method is robust against attempting to call scripts // for entity IDs that no longer exist. - if (_persistentEntitiesScriptEngine && _nonPersistentEntitiesScriptEngine) { + if (_entitiesScriptEngine) { // for all of our previous containing entities, if they are no longer containing then send them a leave event foreach(const EntityItemID& entityID, _currentEntitiesInside) { if (!entitiesContainingAvatar.contains(entityID)) { emit leaveEntity(entityID); - auto entity = getTree()->findEntityByEntityItemID(entityID); - if (entity) { - auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); - } + _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } } @@ -713,11 +671,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { foreach(const EntityItemID& entityID, entitiesContainingAvatar) { if (!_currentEntitiesInside.contains(entityID)) { emit enterEntity(entityID); - auto entity = getTree()->findEntityByEntityItemID(entityID); - if (entity) { - auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - scriptEngine->callEntityScriptMethod(entityID, "enterEntity"); - } + _entitiesScriptEngine->callEntityScriptMethod(entityID, "enterEntity"); } } _currentEntitiesInside = entitiesContainingAvatar; @@ -733,8 +687,8 @@ void EntityTreeRenderer::leaveDomainAndNonOwnedEntities() { EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID); if (entityItem && !(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) { emit leaveEntity(entityID); - if (_nonPersistentEntitiesScriptEngine) { - _nonPersistentEntitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + if (_entitiesScriptEngine) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } } else { currentEntitiesInsideToSave.insert(entityID); @@ -752,12 +706,8 @@ void EntityTreeRenderer::leaveAllEntities() { // for all of our previous containing entities, if they are no longer containing then send them a leave event foreach(const EntityItemID& entityID, _currentEntitiesInside) { emit leaveEntity(entityID); - EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID); - if (entityItem) { - auto& scriptEngine = (entityItem->isLocalEntity() || entityItem->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - if (scriptEngine) { - scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); - } + if (_entitiesScriptEngine) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } } _currentEntitiesInside.clear(); @@ -1053,12 +1003,11 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) { return; } - auto& scriptEngine = (itr->second->getEntity()->isLocalEntity() || itr->second->getEntity()->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - if (_tree && !_shuttingDown && scriptEngine && !itr->second->getEntity()->getScript().isEmpty()) { + if (_tree && !_shuttingDown && _entitiesScriptEngine && !itr->second->getEntity()->getScript().isEmpty()) { if (_currentEntitiesInside.contains(entityID)) { - scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } - scriptEngine->unloadEntityScript(entityID, true); + _entitiesScriptEngine->unloadEntityScript(entityID, true); } auto scene = _viewState->getMain3DScene(); @@ -1103,21 +1052,20 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool if (!entity) { return; } - auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - bool shouldLoad = entity->shouldPreloadScript() && scriptEngine; + bool shouldLoad = entity->shouldPreloadScript() && _entitiesScriptEngine; QString scriptUrl = entity->getScript(); if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) { - if (scriptEngine) { + if (_entitiesScriptEngine) { if (_currentEntitiesInside.contains(entityID)) { - scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } - scriptEngine->unloadEntityScript(entityID); + _entitiesScriptEngine->unloadEntityScript(entityID); } entity->scriptHasUnloaded(); } if (shouldLoad) { entity->setScriptHasFinishedPreload(false); - scriptEngine->loadEntityScript(entityID, resolveScriptURL(scriptUrl), reload); + _entitiesScriptEngine->loadEntityScript(entityID, resolveScriptURL(scriptUrl), reload); entity->scriptHasPreloaded(); } } @@ -1224,9 +1172,8 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons if ((myNodeID == entityASimulatorID && entityAIsDynamic) || (myNodeID == entityBSimulatorID && (!entityAIsDynamic || entityASimulatorID.isNull()))) { playEntityCollisionSound(entityA, collision); emit collisionWithEntity(idA, idB, collision); - auto& scriptEngine = (entityA->isLocalEntity() || entityA->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - if (scriptEngine) { - scriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision); + if (_entitiesScriptEngine) { + _entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision); } } @@ -1236,9 +1183,8 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons Collision invertedCollision(collision); invertedCollision.invert(); emit collisionWithEntity(idB, idA, invertedCollision); - auto& scriptEngine = (entityB->isLocalEntity() || entityB->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - if (scriptEngine) { - scriptEngine->callEntityScriptMethod(idB, "collisionWithEntity", idA, invertedCollision); + if (_entitiesScriptEngine) { + _entitiesScriptEngine->callEntityScriptMethod(idB, "collisionWithEntity", idA, invertedCollision); } } } diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index f7623aad10..149b23702f 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -173,9 +173,7 @@ private: EntityRendererPointer renderableForEntity(const EntityItemPointer& entity) const { return renderableForEntityId(entity->getID()); } render::ItemID renderableIdForEntity(const EntityItemPointer& entity) const { return renderableIdForEntityId(entity->getID()); } - void resetPersistentEntitiesScriptEngine(); - void resetNonPersistentEntitiesScriptEngine(); - void setupEntityScriptEngineSignals(const ScriptEnginePointer& scriptEngine); + void resetEntitiesScriptEngine(); void findBestZoneAndMaybeContainingEntities(QSet& entitiesContainingAvatar); @@ -198,8 +196,7 @@ private: QSet _currentEntitiesInside; bool _wantScripts; - ScriptEnginePointer _nonPersistentEntitiesScriptEngine; // used for domain + non-owned avatar entities, cleared on domain switch - ScriptEnginePointer _persistentEntitiesScriptEngine; // used for local + owned avatar entities, persists on domain switch, cleared on reload content + ScriptEnginePointer _entitiesScriptEngine; void playEntityCollisionSound(const EntityItemPointer& entity, const Collision& collision); @@ -217,6 +214,8 @@ private: std::function _getPrevRayPickResultOperator; std::function _setPrecisionPickingOperator; + bool _mouseAndPreloadSignalHandlersConnected { false }; + class LayeredZone { public: LayeredZone(std::shared_ptr zone) : zone(zone), id(zone->getID()), volume(zone->getVolumeEstimate()) {} diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 36beb9f0d3..05947551ba 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1046,26 +1046,18 @@ QSizeF EntityScriptingInterface::textSize(const QUuid& id, const QString& text) return EntityTree::textSize(id, text); } -void EntityScriptingInterface::setPersistentEntitiesScriptEngine(QSharedPointer engine) { +void EntityScriptingInterface::setEntitiesScriptEngine(QSharedPointer engine) { std::lock_guard lock(_entitiesScriptEngineLock); - _persistentEntitiesScriptEngine = engine; -} - -void EntityScriptingInterface::setNonPersistentEntitiesScriptEngine(QSharedPointer engine) { - std::lock_guard lock(_entitiesScriptEngineLock); - _nonPersistentEntitiesScriptEngine = engine; + _entitiesScriptEngine = engine; } void EntityScriptingInterface::callEntityMethod(const QUuid& id, const QString& method, const QStringList& params) { PROFILE_RANGE(script_entities, __FUNCTION__); - - auto entity = getEntityTree()->findEntityByEntityItemID(id); - if (entity) { - std::lock_guard lock(_entitiesScriptEngineLock); - auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - if (scriptEngine) { - scriptEngine->callEntityScriptMethod(id, method, params); - } + + std::lock_guard lock(_entitiesScriptEngineLock); + if (_entitiesScriptEngine) { + EntityItemID entityID{ id }; + _entitiesScriptEngine->callEntityScriptMethod(entityID, method, params); } } @@ -1107,13 +1099,9 @@ void EntityScriptingInterface::handleEntityScriptCallMethodPacket(QSharedPointer params << paramString; } - auto entity = getEntityTree()->findEntityByEntityItemID(entityID); - if (entity) { - std::lock_guard lock(_entitiesScriptEngineLock); - auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; - if (scriptEngine) { - scriptEngine->callEntityScriptMethod(entityID, method, params, senderNode->getUUID()); - } + std::lock_guard lock(_entitiesScriptEngineLock); + if (_entitiesScriptEngine) { + _entitiesScriptEngine->callEntityScriptMethod(entityID, method, params, senderNode->getUUID()); } } } @@ -1344,7 +1332,7 @@ bool EntityPropertyMetadataRequest::script(EntityItemID entityID, QScriptValue h if (entitiesScriptEngine) { request->setFuture(entitiesScriptEngine->getLocalEntityScriptDetails(entityID)); } - }, entityID); + }); if (!request->isStarted()) { request->deleteLater(); callScopedHandlerObject(handler, _engine->makeError("Entities Scripting Provider unavailable", "InternalError"), QScriptValue()); diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 14d853fbaf..fca0dad871 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -181,8 +181,7 @@ public: void setEntityTree(EntityTreePointer modelTree); EntityTreePointer getEntityTree() { return _entityTree; } - void setPersistentEntitiesScriptEngine(QSharedPointer engine); - void setNonPersistentEntitiesScriptEngine(QSharedPointer engine); + void setEntitiesScriptEngine(QSharedPointer engine); void resetActivityTracking(); ActivityTracking getActivityTracking() const { return _activityTracking; } @@ -2511,12 +2510,9 @@ signals: void webEventReceived(const EntityItemID& entityItemID, const QVariant& message); protected: - void withEntitiesScriptEngine(std::function)> function, const EntityItemID& id) { - auto entity = getEntityTree()->findEntityByEntityItemID(id); - if (entity) { - std::lock_guard lock(_entitiesScriptEngineLock); - function((entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine); - } + void withEntitiesScriptEngine(std::function)> function) { + std::lock_guard lock(_entitiesScriptEngineLock); + function(_entitiesScriptEngine); }; private slots: @@ -2546,8 +2542,7 @@ private: EntityTreePointer _entityTree; std::recursive_mutex _entitiesScriptEngineLock; - QSharedPointer _persistentEntitiesScriptEngine; - QSharedPointer _nonPersistentEntitiesScriptEngine; + QSharedPointer _entitiesScriptEngine; bool _bidOnSimulationOwnership { false }; From 81940214bb943958611d1789d6cd6fb52dfb523b Mon Sep 17 00:00:00 2001 From: HifiExperiments <53453710+HifiExperiments@users.noreply.github.com> Date: Mon, 16 Nov 2020 21:20:25 -0800 Subject: [PATCH 08/28] Revert "Revert "Split Local and owned Avatar Entity scripts into their own ScriptEngine"" --- .../src/scripts/EntityScriptServer.cpp | 4 +- .../src/EntityTreeRenderer.cpp | 230 +++++++++++------- .../src/EntityTreeRenderer.h | 9 +- .../entities/src/EntityScriptingInterface.cpp | 34 ++- .../entities/src/EntityScriptingInterface.h | 15 +- 5 files changed, 183 insertions(+), 109 deletions(-) diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index 065ab12abc..16931e8c26 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -470,7 +470,9 @@ void EntityScriptServer::resetEntitiesScriptEngine() { scriptEngines->runScriptInitializers(newEngine); newEngine->runInThread(); auto newEngineSP = qSharedPointerCast(newEngine); - DependencyManager::get()->setEntitiesScriptEngine(newEngineSP); + // On the entity script server, these are the same + DependencyManager::get()->setPersistentEntitiesScriptEngine(newEngineSP); + DependencyManager::get()->setNonPersistentEntitiesScriptEngine(newEngineSP); if (_entitiesScriptEngine) { disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 3538f07d32..2f9c8c4b3a 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -158,79 +158,98 @@ render::ItemID EntityTreeRenderer::renderableIdForEntityId(const EntityItemID& i int EntityTreeRenderer::_entitiesScriptEngineCount = 0; -void EntityTreeRenderer::resetEntitiesScriptEngine() { - _entitiesScriptEngine = scriptEngineFactory(ScriptEngine::ENTITY_CLIENT_SCRIPT, NO_SCRIPT, - QString("about:Entities %1").arg(++_entitiesScriptEngineCount)); - DependencyManager::get()->runScriptInitializers(_entitiesScriptEngine); - _entitiesScriptEngine->runInThread(); - auto entitiesScriptEngineProvider = qSharedPointerCast(_entitiesScriptEngine); +void EntityTreeRenderer::setupEntityScriptEngineSignals(const ScriptEnginePointer& scriptEngine) { auto entityScriptingInterface = DependencyManager::get(); - entityScriptingInterface->setEntitiesScriptEngine(entitiesScriptEngineProvider); - connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptPreloadFinished, [&](const EntityItemID& entityID) { + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mousePressOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "mousePressOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseDoublePressOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "mouseDoublePressOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseMoveOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "mouseMoveOnEntity", event); + // FIXME: this is a duplicate of mouseMoveOnEntity, but it seems like some scripts might use this naming + scriptEngine->callEntityScriptMethod(entityID, "mouseMoveEvent", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseReleaseOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "mouseReleaseOnEntity", event); + }); + + connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "clickDownOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::holdingClickOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "holdingClickOnEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickReleaseOnEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "clickReleaseOnEntity", event); + }); + + connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverEnterEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "hoverEnterEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverOverEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "hoverOverEntity", event); + }); + connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, scriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { + scriptEngine->callEntityScriptMethod(entityID, "hoverLeaveEntity", event); + }); + + connect(scriptEngine.data(), &ScriptEngine::entityScriptPreloadFinished, [&](const EntityItemID& entityID) { EntityItemPointer entity = getTree()->findEntityByID(entityID); if (entity) { entity->setScriptHasFinishedPreload(true); } }); +} - // Connect mouse events to entity script callbacks - if (!_mouseAndPreloadSignalHandlersConnected) { - - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mousePressOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "mousePressOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseDoublePressOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseDoublePressOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseMoveOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseMoveOnEntity", event); - // FIXME: this is a duplicate of mouseMoveOnEntity, but it seems like some scripts might use this naming - _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseMoveEvent", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::mouseReleaseOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "mouseReleaseOnEntity", event); - }); - - connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "clickDownOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::holdingClickOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "holdingClickOnEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickReleaseOnEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "clickReleaseOnEntity", event); - }); - - connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverEnterEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverEnterEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverOverEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverOverEntity", event); - }); - connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, _entitiesScriptEngine.data(), [&](const EntityItemID& entityID, const PointerEvent& event) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "hoverLeaveEntity", event); - }); - - _mouseAndPreloadSignalHandlersConnected = true; +void EntityTreeRenderer::resetPersistentEntitiesScriptEngine() { + if (_persistentEntitiesScriptEngine) { + _persistentEntitiesScriptEngine->unloadAllEntityScripts(true); + _persistentEntitiesScriptEngine->stop(); + _persistentEntitiesScriptEngine->waitTillDoneRunning(); + _persistentEntitiesScriptEngine->disconnectNonEssentialSignals(); } + _persistentEntitiesScriptEngine = scriptEngineFactory(ScriptEngine::ENTITY_CLIENT_SCRIPT, NO_SCRIPT, + QString("about:Entities %1").arg(++_entitiesScriptEngineCount)); + DependencyManager::get()->runScriptInitializers(_persistentEntitiesScriptEngine); + _persistentEntitiesScriptEngine->runInThread(); + auto entitiesScriptEngineProvider = qSharedPointerCast(_persistentEntitiesScriptEngine); + auto entityScriptingInterface = DependencyManager::get(); + entityScriptingInterface->setPersistentEntitiesScriptEngine(entitiesScriptEngineProvider); + + setupEntityScriptEngineSignals(_persistentEntitiesScriptEngine); +} + +void EntityTreeRenderer::resetNonPersistentEntitiesScriptEngine() { + if (_nonPersistentEntitiesScriptEngine) { + _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(false); + _nonPersistentEntitiesScriptEngine->stop(); + _nonPersistentEntitiesScriptEngine->waitTillDoneRunning(); + _nonPersistentEntitiesScriptEngine->disconnectNonEssentialSignals(); + } + _nonPersistentEntitiesScriptEngine = scriptEngineFactory(ScriptEngine::ENTITY_CLIENT_SCRIPT, NO_SCRIPT, + QString("about:Entities %1").arg(++_entitiesScriptEngineCount)); + DependencyManager::get()->runScriptInitializers(_nonPersistentEntitiesScriptEngine); + _nonPersistentEntitiesScriptEngine->runInThread(); + auto entitiesScriptEngineProvider = qSharedPointerCast(_nonPersistentEntitiesScriptEngine); + DependencyManager::get()->setNonPersistentEntitiesScriptEngine(entitiesScriptEngineProvider); + + setupEntityScriptEngineSignals(_nonPersistentEntitiesScriptEngine); } void EntityTreeRenderer::stopDomainAndNonOwnedEntities() { leaveDomainAndNonOwnedEntities(); // unload and stop the engine - if (_entitiesScriptEngine) { - QList entitiesWithEntityScripts = _entitiesScriptEngine->getListOfEntityScriptIDs(); + if (_nonPersistentEntitiesScriptEngine) { + QList entitiesWithEntityScripts = _nonPersistentEntitiesScriptEngine->getListOfEntityScriptIDs(); - foreach (const EntityItemID& entityID, entitiesWithEntityScripts) { + foreach (const EntityItemID& entityID, entitiesWithEntityScripts) { EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID); - if (entityItem && !entityItem->getScript().isEmpty()) { if (!(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) { - if (_currentEntitiesInside.contains(entityID)) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); - } - _entitiesScriptEngine->unloadEntityScript(entityID, true); + _nonPersistentEntitiesScriptEngine->unloadEntityScript(entityID, true); } } } @@ -240,6 +259,10 @@ void EntityTreeRenderer::stopDomainAndNonOwnedEntities() { void EntityTreeRenderer::clearDomainAndNonOwnedEntities() { stopDomainAndNonOwnedEntities(); + if (!_shuttingDown && _wantScripts) { + resetNonPersistentEntitiesScriptEngine(); + } + std::unordered_map savedEntities; std::unordered_set savedRenderables; // remove all entities from the scene @@ -269,16 +292,22 @@ void EntityTreeRenderer::clearDomainAndNonOwnedEntities() { void EntityTreeRenderer::clear() { leaveAllEntities(); - // unload and stop the engine - if (_entitiesScriptEngine) { - // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread - _entitiesScriptEngine->unloadAllEntityScripts(true); - _entitiesScriptEngine->stop(); - } // reset the engine auto scene = _viewState->getMain3DScene(); if (_shuttingDown) { + // unload and stop the engines + if (_nonPersistentEntitiesScriptEngine) { + // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread + _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(true); + _nonPersistentEntitiesScriptEngine->stop(); + } + if (_persistentEntitiesScriptEngine) { + // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread + _persistentEntitiesScriptEngine->unloadAllEntityScripts(true); + _persistentEntitiesScriptEngine->stop(); + } + if (scene) { render::Transaction transaction; for (const auto& entry : _entitiesInScene) { @@ -289,7 +318,8 @@ void EntityTreeRenderer::clear() { } } else { if (_wantScripts) { - resetEntitiesScriptEngine(); + resetPersistentEntitiesScriptEngine(); + resetNonPersistentEntitiesScriptEngine(); } if (scene) { for (const auto& entry : _entitiesInScene) { @@ -313,13 +343,17 @@ void EntityTreeRenderer::clear() { } void EntityTreeRenderer::reloadEntityScripts() { - _entitiesScriptEngine->unloadAllEntityScripts(); - _entitiesScriptEngine->resetModuleCache(); + _persistentEntitiesScriptEngine->unloadAllEntityScripts(); + _persistentEntitiesScriptEngine->resetModuleCache(); + _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(); + _nonPersistentEntitiesScriptEngine->resetModuleCache(); + for (const auto& entry : _entitiesInScene) { const auto& renderer = entry.second; const auto& entity = renderer->getEntity(); - if (!entity->getScript().isEmpty()) { - _entitiesScriptEngine->loadEntityScript(entity->getEntityItemID(), resolveScriptURL(entity->getScript()), true); + if (entity && !entity->getScript().isEmpty()) { + auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + scriptEngine->loadEntityScript(entity->getEntityItemID(), resolveScriptURL(entity->getScript()), true); } } } @@ -329,7 +363,8 @@ void EntityTreeRenderer::init() { EntityTreePointer entityTree = std::static_pointer_cast(_tree); if (_wantScripts) { - resetEntitiesScriptEngine(); + resetPersistentEntitiesScriptEngine(); + resetNonPersistentEntitiesScriptEngine(); } forceRecheckEntities(); // setup our state to force checking our inside/outsideness of entities @@ -341,8 +376,11 @@ void EntityTreeRenderer::init() { } void EntityTreeRenderer::shutdown() { - if (_entitiesScriptEngine) { - _entitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential + if (_persistentEntitiesScriptEngine) { + _persistentEntitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential + } + if (_nonPersistentEntitiesScriptEngine) { + _nonPersistentEntitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential } _shuttingDown = true; @@ -658,12 +696,16 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { // EntityItemIDs from here. The callEntityScriptMethod() method is robust against attempting to call scripts // for entity IDs that no longer exist. - if (_entitiesScriptEngine) { + if (_persistentEntitiesScriptEngine && _nonPersistentEntitiesScriptEngine) { // for all of our previous containing entities, if they are no longer containing then send them a leave event foreach(const EntityItemID& entityID, _currentEntitiesInside) { if (!entitiesContainingAvatar.contains(entityID)) { emit leaveEntity(entityID); - _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + auto entity = getTree()->findEntityByEntityItemID(entityID); + if (entity) { + auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + } } } @@ -671,7 +713,11 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { foreach(const EntityItemID& entityID, entitiesContainingAvatar) { if (!_currentEntitiesInside.contains(entityID)) { emit enterEntity(entityID); - _entitiesScriptEngine->callEntityScriptMethod(entityID, "enterEntity"); + auto entity = getTree()->findEntityByEntityItemID(entityID); + if (entity) { + auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + scriptEngine->callEntityScriptMethod(entityID, "enterEntity"); + } } } _currentEntitiesInside = entitiesContainingAvatar; @@ -687,8 +733,8 @@ void EntityTreeRenderer::leaveDomainAndNonOwnedEntities() { EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID); if (entityItem && !(entityItem->isLocalEntity() || entityItem->isMyAvatarEntity())) { emit leaveEntity(entityID); - if (_entitiesScriptEngine) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + if (_nonPersistentEntitiesScriptEngine) { + _nonPersistentEntitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } } else { currentEntitiesInsideToSave.insert(entityID); @@ -706,8 +752,12 @@ void EntityTreeRenderer::leaveAllEntities() { // for all of our previous containing entities, if they are no longer containing then send them a leave event foreach(const EntityItemID& entityID, _currentEntitiesInside) { emit leaveEntity(entityID); - if (_entitiesScriptEngine) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + EntityItemPointer entityItem = getTree()->findEntityByEntityItemID(entityID); + if (entityItem) { + auto& scriptEngine = (entityItem->isLocalEntity() || entityItem->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + if (scriptEngine) { + scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + } } } _currentEntitiesInside.clear(); @@ -1003,11 +1053,12 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) { return; } - if (_tree && !_shuttingDown && _entitiesScriptEngine && !itr->second->getEntity()->getScript().isEmpty()) { + auto& scriptEngine = (itr->second->getEntity()->isLocalEntity() || itr->second->getEntity()->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + if (_tree && !_shuttingDown && scriptEngine && !itr->second->getEntity()->getScript().isEmpty()) { if (_currentEntitiesInside.contains(entityID)) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } - _entitiesScriptEngine->unloadEntityScript(entityID, true); + scriptEngine->unloadEntityScript(entityID, true); } auto scene = _viewState->getMain3DScene(); @@ -1052,20 +1103,21 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool if (!entity) { return; } - bool shouldLoad = entity->shouldPreloadScript() && _entitiesScriptEngine; + auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + bool shouldLoad = entity->shouldPreloadScript() && scriptEngine; QString scriptUrl = entity->getScript(); if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) { - if (_entitiesScriptEngine) { + if (scriptEngine) { if (_currentEntitiesInside.contains(entityID)) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); + scriptEngine->callEntityScriptMethod(entityID, "leaveEntity"); } - _entitiesScriptEngine->unloadEntityScript(entityID); + scriptEngine->unloadEntityScript(entityID); } entity->scriptHasUnloaded(); } if (shouldLoad) { entity->setScriptHasFinishedPreload(false); - _entitiesScriptEngine->loadEntityScript(entityID, resolveScriptURL(scriptUrl), reload); + scriptEngine->loadEntityScript(entityID, resolveScriptURL(scriptUrl), reload); entity->scriptHasPreloaded(); } } @@ -1172,8 +1224,9 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons if ((myNodeID == entityASimulatorID && entityAIsDynamic) || (myNodeID == entityBSimulatorID && (!entityAIsDynamic || entityASimulatorID.isNull()))) { playEntityCollisionSound(entityA, collision); emit collisionWithEntity(idA, idB, collision); - if (_entitiesScriptEngine) { - _entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision); + auto& scriptEngine = (entityA->isLocalEntity() || entityA->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + if (scriptEngine) { + scriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision); } } @@ -1183,8 +1236,9 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons Collision invertedCollision(collision); invertedCollision.invert(); emit collisionWithEntity(idB, idA, invertedCollision); - if (_entitiesScriptEngine) { - _entitiesScriptEngine->callEntityScriptMethod(idB, "collisionWithEntity", idA, invertedCollision); + auto& scriptEngine = (entityB->isLocalEntity() || entityB->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + if (scriptEngine) { + scriptEngine->callEntityScriptMethod(idB, "collisionWithEntity", idA, invertedCollision); } } } diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index 149b23702f..f7623aad10 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -173,7 +173,9 @@ private: EntityRendererPointer renderableForEntity(const EntityItemPointer& entity) const { return renderableForEntityId(entity->getID()); } render::ItemID renderableIdForEntity(const EntityItemPointer& entity) const { return renderableIdForEntityId(entity->getID()); } - void resetEntitiesScriptEngine(); + void resetPersistentEntitiesScriptEngine(); + void resetNonPersistentEntitiesScriptEngine(); + void setupEntityScriptEngineSignals(const ScriptEnginePointer& scriptEngine); void findBestZoneAndMaybeContainingEntities(QSet& entitiesContainingAvatar); @@ -196,7 +198,8 @@ private: QSet _currentEntitiesInside; bool _wantScripts; - ScriptEnginePointer _entitiesScriptEngine; + ScriptEnginePointer _nonPersistentEntitiesScriptEngine; // used for domain + non-owned avatar entities, cleared on domain switch + ScriptEnginePointer _persistentEntitiesScriptEngine; // used for local + owned avatar entities, persists on domain switch, cleared on reload content void playEntityCollisionSound(const EntityItemPointer& entity, const Collision& collision); @@ -214,8 +217,6 @@ private: std::function _getPrevRayPickResultOperator; std::function _setPrecisionPickingOperator; - bool _mouseAndPreloadSignalHandlersConnected { false }; - class LayeredZone { public: LayeredZone(std::shared_ptr zone) : zone(zone), id(zone->getID()), volume(zone->getVolumeEstimate()) {} diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 05947551ba..36beb9f0d3 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1046,18 +1046,26 @@ QSizeF EntityScriptingInterface::textSize(const QUuid& id, const QString& text) return EntityTree::textSize(id, text); } -void EntityScriptingInterface::setEntitiesScriptEngine(QSharedPointer engine) { +void EntityScriptingInterface::setPersistentEntitiesScriptEngine(QSharedPointer engine) { std::lock_guard lock(_entitiesScriptEngineLock); - _entitiesScriptEngine = engine; + _persistentEntitiesScriptEngine = engine; +} + +void EntityScriptingInterface::setNonPersistentEntitiesScriptEngine(QSharedPointer engine) { + std::lock_guard lock(_entitiesScriptEngineLock); + _nonPersistentEntitiesScriptEngine = engine; } void EntityScriptingInterface::callEntityMethod(const QUuid& id, const QString& method, const QStringList& params) { PROFILE_RANGE(script_entities, __FUNCTION__); - - std::lock_guard lock(_entitiesScriptEngineLock); - if (_entitiesScriptEngine) { - EntityItemID entityID{ id }; - _entitiesScriptEngine->callEntityScriptMethod(entityID, method, params); + + auto entity = getEntityTree()->findEntityByEntityItemID(id); + if (entity) { + std::lock_guard lock(_entitiesScriptEngineLock); + auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + if (scriptEngine) { + scriptEngine->callEntityScriptMethod(id, method, params); + } } } @@ -1099,9 +1107,13 @@ void EntityScriptingInterface::handleEntityScriptCallMethodPacket(QSharedPointer params << paramString; } - std::lock_guard lock(_entitiesScriptEngineLock); - if (_entitiesScriptEngine) { - _entitiesScriptEngine->callEntityScriptMethod(entityID, method, params, senderNode->getUUID()); + auto entity = getEntityTree()->findEntityByEntityItemID(entityID); + if (entity) { + std::lock_guard lock(_entitiesScriptEngineLock); + auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine; + if (scriptEngine) { + scriptEngine->callEntityScriptMethod(entityID, method, params, senderNode->getUUID()); + } } } } @@ -1332,7 +1344,7 @@ bool EntityPropertyMetadataRequest::script(EntityItemID entityID, QScriptValue h if (entitiesScriptEngine) { request->setFuture(entitiesScriptEngine->getLocalEntityScriptDetails(entityID)); } - }); + }, entityID); if (!request->isStarted()) { request->deleteLater(); callScopedHandlerObject(handler, _engine->makeError("Entities Scripting Provider unavailable", "InternalError"), QScriptValue()); diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index fca0dad871..14d853fbaf 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -181,7 +181,8 @@ public: void setEntityTree(EntityTreePointer modelTree); EntityTreePointer getEntityTree() { return _entityTree; } - void setEntitiesScriptEngine(QSharedPointer engine); + void setPersistentEntitiesScriptEngine(QSharedPointer engine); + void setNonPersistentEntitiesScriptEngine(QSharedPointer engine); void resetActivityTracking(); ActivityTracking getActivityTracking() const { return _activityTracking; } @@ -2510,9 +2511,12 @@ signals: void webEventReceived(const EntityItemID& entityItemID, const QVariant& message); protected: - void withEntitiesScriptEngine(std::function)> function) { - std::lock_guard lock(_entitiesScriptEngineLock); - function(_entitiesScriptEngine); + void withEntitiesScriptEngine(std::function)> function, const EntityItemID& id) { + auto entity = getEntityTree()->findEntityByEntityItemID(id); + if (entity) { + std::lock_guard lock(_entitiesScriptEngineLock); + function((entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptEngine : _nonPersistentEntitiesScriptEngine); + } }; private slots: @@ -2542,7 +2546,8 @@ private: EntityTreePointer _entityTree; std::recursive_mutex _entitiesScriptEngineLock; - QSharedPointer _entitiesScriptEngine; + QSharedPointer _persistentEntitiesScriptEngine; + QSharedPointer _nonPersistentEntitiesScriptEngine; bool _bidOnSimulationOwnership { false }; From b6744588f491869b0f2105fc69ef15244d9b2403 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 16 Nov 2020 21:25:25 -0800 Subject: [PATCH 09/28] loading fix --- .../entities-renderer/src/EntityTreeRenderer.cpp | 2 +- libraries/script-engine/src/ScriptEngine.cpp | 16 +++++++++------- libraries/script-engine/src/ScriptEngine.h | 2 +- libraries/script-engine/src/ScriptEngines.cpp | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 2f9c8c4b3a..949ad85945 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -224,7 +224,7 @@ void EntityTreeRenderer::resetPersistentEntitiesScriptEngine() { void EntityTreeRenderer::resetNonPersistentEntitiesScriptEngine() { if (_nonPersistentEntitiesScriptEngine) { - _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(false); + _nonPersistentEntitiesScriptEngine->unloadAllEntityScripts(true); _nonPersistentEntitiesScriptEngine->stop(); _nonPersistentEntitiesScriptEngine->waitTillDoneRunning(); _nonPersistentEntitiesScriptEngine->disconnectNonEssentialSignals(); diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 9480b498ba..f42178b023 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -451,7 +451,7 @@ void ScriptEngine::executeOnScriptThread(std::function function, const Q function(); } -void ScriptEngine::waitTillDoneRunning() { +void ScriptEngine::waitTillDoneRunning(bool shutdown) { // Engine should be stopped already, but be defensive stop(); @@ -520,12 +520,14 @@ void ScriptEngine::waitTillDoneRunning() { } } - // NOTE: This will be called on the main application thread (among other threads) from stopAllScripts. - // The thread will need to continue to process events, because - // the scripts will likely need to marshall messages across to the main thread, e.g. - // if they access Settings or Menu in any of their shutdown code. So: - // Process events for this thread, allowing invokeMethod calls to pass between threads. - QCoreApplication::processEvents(); + if (shutdown) { + // NOTE: This will be called on the main application thread (among other threads) from stopAllScripts. + // The thread will need to continue to process events, because + // the scripts will likely need to marshall messages across to the main thread, e.g. + // if they access Settings or Menu in any of their shutdown code. So: + // Process events for this thread, allowing invokeMethod calls to pass between threads. + QCoreApplication::processEvents(); + } // Avoid a pure busy wait QThread::yieldCurrentThread(); diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 8cbeed58af..1d85de4d94 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -197,7 +197,7 @@ public: Q_INVOKABLE void stop(bool marshal = false); // Stop any evaluating scripts and wait for the scripting thread to finish. - void waitTillDoneRunning(); + void waitTillDoneRunning(bool shutdown = false); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // NOTE - these are NOT intended to be public interfaces available to scripts, the are only Q_INVOKABLE so we can diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index 12eaa011a9..381d931620 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -182,7 +182,7 @@ void ScriptEngines::shutdownScripting() { // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing // any application state after we leave this stopAllScripts() method qCDebug(scriptengine) << "waiting on script:" << scriptName; - scriptEngine->waitTillDoneRunning(); + scriptEngine->waitTillDoneRunning(true); qCDebug(scriptengine) << "done waiting on script:" << scriptName; } // Once the script is stopped, we can remove it from our set From 4c536f43184cb6c1abfdf3d9779a4333a3f2a215 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 16 Nov 2020 22:11:14 -0800 Subject: [PATCH 10/28] try to replace set-env --- .github/workflows/master_build.yml | 42 +++++++++++++++--------------- .github/workflows/pr_build.yml | 34 ++++++++++++------------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index 824c279845..ac718c9bcd 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -48,36 +48,36 @@ jobs: shell: bash id: buildenv1 run: | - echo ::set-env name=UPLOAD_PREFIX::master - echo ::set-env name=GIT_COMMIT_SHORT::`echo $GIT_COMMIT | cut -c1-7` - echo ::set-env name=JOB_NAME::"build (${{matrix.os}}, ${{matrix.build_type}})" + echo "UPLOAD_PREFIX=master" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV + echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})` >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then - echo ::set-env name=PYTHON_EXEC::python3 - echo ::set-env name=INSTALLER_EXT::tgz - echo ::set-env name=CMAKE_BUILD_EXTRA::"-- -j3" - echo ::set-env name=CMAKE_EXTRA::"-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" + echo "PYTHON_EXEC=python3" >> $GITHUB_ENV + echo "INSTALLER_EXT=tgz" >> $GITHUB_ENV + echo "CMAKE_BUILD_EXTRA=`-- -j3`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)`" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then - echo ::set-env name=PYTHON_EXEC::python3 - echo ::set-env name=ZIP_COMMAND::zip - echo ::set-env name=ZIP_ARGS::-r - echo ::set-env name=INSTALLER_EXT::dmg - echo ::set-env name=CMAKE_EXTRA::"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" + echo "PYTHON_EXEC=python3" >> $GITHUB_ENV + echo "ZIP_COMMAND=zip" >> $GITHUB_ENV + echo "ZIP_ARGS=-r" >> $GITHUB_ENV + echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode`" >> $GITHUB_ENV echo "::set-output name=symbols_archive::${BUILD_NUMBER}-${{ matrix.build_type }}-mac-symbols.zip" fi # Windows build variables if [ "${{ matrix.os }}" = "windows-latest" ]; then - echo ::set-env name=PYTHON_EXEC::python - echo ::set-env name=ZIP_COMMAND::7z - echo ::set-env name=ZIP_ARGS::a - echo ::set-env name=INSTALLER_EXT::exe - echo ::set-env name=CMAKE_EXTRA::"-A x64" - echo "::set-env name=SYMBOL_REGEX::\(exe\|dll\|pdb\)" - echo "::set-output name=symbols_archive::${BUILD_NUMBER}-${{ matrix.build_type }}-win-symbols.zip" - # echo ::set-env name=HF_PFX_PASSPHRASE::${{secrets.pfx_key}} - # echo "::set-env name=HF_PFX_FILE::${{runner.workspace}}\build\codesign.pfx" + echo "PYTHON_EXEC=python" >> $GITHUB_ENV + echo "ZIP_COMMAND=7z" >> $GITHUB_ENV + echo "ZIP_ARGS=a" >> $GITHUB_ENV + echo "INSTALLER_EXT=exe" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-A x64`" >> $GITHUB_ENV + echo "SYMBOL_REGEX=\(exe\|dll\|pdb\)" >> $GITHUB_ENV + echo "symbols_archive=${BUILD_NUMBER}-${{ matrix.build_type }}-win-symbols.zip" >> $GITHUB_ENV + # echo "HF_PFX_PASSPHRASE=${{secrets.pfx_key}}" >> $GITHUB_ENV + # echo "HF_PFX_FILE=${{runner.workspace}}\build\codesign.pfx"" >> $GITHUB_ENV fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure build environment 2 diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 3c6b91c65b..b41304100f 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -49,34 +49,34 @@ jobs: shell: bash id: buildenv1 run: | - echo ::set-env name=GIT_COMMIT_SHORT::`echo $GIT_COMMIT | cut -c1-7` - echo ::set-env name=JOB_NAME::"build (${{matrix.os}}, ${{matrix.build_type}})" + echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV + echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})`" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then - echo ::set-env name=PYTHON_EXEC::python3 - echo ::set-env name=INSTALLER_EXT::* - echo ::set-env name=CMAKE_BUILD_EXTRA::"-- -j3" - echo ::set-env name=CMAKE_EXTRA::"-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" + echo "PYTHON_EXEC=python3" >> $GITHUB_ENV + echo "INSTALLER_EXT=*" >> $GITHUB_ENV + echo "CMAKE_BUILD_EXTRA=`-- -j3`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)`" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then - echo ::set-env name=PYTHON_EXEC::python3 - echo ::set-env name=INSTALLER_EXT::dmg - echo ::set-env name=CMAKE_EXTRA::"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" + echo "PYTHON_EXEC=python3" >> $GITHUB_ENV + echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode`" >> $GITHUB_ENV fi # Windows build variables if [ "${{ matrix.os }}" = "windows-latest" ]; then - echo ::set-env name=PYTHON_EXEC::python - echo ::set-env name=INSTALLER_EXT::exe - echo ::set-env name=CMAKE_EXTRA::"-A x64" + echo "PYTHON_EXEC=python" >> $GITHUB_ENV + echo "INSTALLER_EXT=exe" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-A x64`" >> $GITHUB_ENV fi # Android + Quest build variables if [[ "${{ matrix.build_type }}" == "android" ]]; then HIFI_ANDROID_PRECOMPILED="${{runner.workspace}}/dependencies" - echo ::set-env name=HIFI_ANDROID_PRECOMPILED::"$HIFI_ANDROID_PRECOMPILED" + echo "HIFI_ANDROID_PRECOMPILED=`$HIFI_ANDROID_PRECOMPILED`" >> $GITHUB_ENV mkdir $HIFI_ANDROID_PRECOMPILED - echo ::set-env name=INSTALLER_EXT::apk + echo "INSTALLER_EXT=apk" >> $GITHUB_ENV fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure Build Environment 2 @@ -84,11 +84,11 @@ jobs: run: | echo "${{ steps.buildenv1.outputs.symbols_archive }}" if [[ "${{ matrix.build_type }}" != "android" ]]; then - echo ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT + echo "ARTIFACT_PATTERN=Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables - echo ::set-env name=INSTALLER::Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV else - echo ::set-env name=ARTIFACT_PATTERN::*.$INSTALLER_EXT + echo "ARTIFACT_PATTERN=*.$INSTALLER_EXT" >> $GITHUB_ENV fi - name: Clear Working Directory if: startsWith(matrix.os, 'windows') From 5b8f7fad165d6f4b1f9d1ffb6549c1e1ac679b7f Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 16 Nov 2020 22:18:43 -0800 Subject: [PATCH 11/28] some more --- .github/workflows/master_build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index ac718c9bcd..505efe0171 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -50,7 +50,7 @@ jobs: run: | echo "UPLOAD_PREFIX=master" >> $GITHUB_ENV echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV - echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})` >> $GITHUB_ENV + echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})`" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV @@ -77,21 +77,21 @@ jobs: echo "SYMBOL_REGEX=\(exe\|dll\|pdb\)" >> $GITHUB_ENV echo "symbols_archive=${BUILD_NUMBER}-${{ matrix.build_type }}-win-symbols.zip" >> $GITHUB_ENV # echo "HF_PFX_PASSPHRASE=${{secrets.pfx_key}}" >> $GITHUB_ENV - # echo "HF_PFX_FILE=${{runner.workspace}}\build\codesign.pfx"" >> $GITHUB_ENV + # echo "HF_PFX_FILE=${{runner.workspace}}\build\codesign.pfx" >> $GITHUB_ENV fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure build environment 2 shell: bash run: | echo "${{ steps.buildenv1.outputs.symbols_archive }}" - echo ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-*.$INSTALLER_EXT + echo "ARTIFACT_PATTERN=Vircadia-Alpha-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables if [ "${{ matrix.build_type }}" = "full" ]; then - echo ::set-env name=CLIENT_ONLY::FALSE - echo ::set-env name=INSTALLER::Vircadia-Alpha-$BUILD_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + echo "CLIENT_ONLY=FALSE" >> $GITHUB_ENV + echo "INSTALLER=Vircadia-Alpha-$BUILD_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV else - echo ::set-env name=CLIENT_ONLY::TRUE - echo ::set-env name=INSTALLER::Vircadia-Alpha-Interface-$BUILD_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + echo "CLIENT_ONLY=TRUE" >> $GITHUB_ENV + echo "INSTALLER=Vircadia-Alpha-Interface-$BUILD_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV fi - name: Clear working directory if: startsWith(matrix.os, 'windows') From cfe824c1805bf1bda4cbcc3434161b77ca2e6616 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 08:16:25 +1300 Subject: [PATCH 12/28] Replace set-env in PR GHA Code from commit 4c536f4 by HifiExperiments. --- .github/workflows/pr_build.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index f28cf1e66b..5eb8e2a647 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -43,36 +43,36 @@ jobs: shell: bash id: buildenv1 run: | - echo ::set-env name=GIT_COMMIT_SHORT::`echo $GIT_COMMIT | cut -c1-7` - echo ::set-env name=JOB_NAME::"build (${{matrix.os}}, ${{matrix.build_type}})" + echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV + echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})`" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then - echo ::set-env name=PYTHON_EXEC::python3 - echo ::set-env name=INSTALLER_EXT::* - echo ::set-env name=CMAKE_BUILD_EXTRA::"-- -j3" - echo ::set-env name=CMAKE_EXTRA::"-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" + echo "PYTHON_EXEC=python3" >> $GITHUB_ENV + echo "INSTALLER_EXT=*" >> $GITHUB_ENV + echo "CMAKE_BUILD_EXTRA=`-- -j3`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)`" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then - echo ::set-env name=PYTHON_EXEC::python3 - echo ::set-env name=INSTALLER_EXT::dmg - echo ::set-env name=CMAKE_EXTRA::"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" + echo "PYTHON_EXEC=python3" >> $GITHUB_ENV + echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode`" >> $GITHUB_ENV fi # Windows build variables if [ "${{ matrix.os }}" = "windows-latest" ]; then - echo ::set-env name=PYTHON_EXEC::python - echo ::set-env name=INSTALLER_EXT::exe - echo ::set-env name=CMAKE_EXTRA::"-A x64" + echo "PYTHON_EXEC=python" >> $GITHUB_ENV + echo "INSTALLER_EXT=exe" >> $GITHUB_ENV + echo "CMAKE_EXTRA=`-A x64`" >> $GITHUB_ENV fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure Build Environment 2 shell: bash run: | echo "${{ steps.buildenv1.outputs.symbols_archive }}" - echo ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT + echo "ARTIFACT_PATTERN=Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables - echo ::set-env name=INSTALLER::Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV - name: Clear Working Directory if: startsWith(matrix.os, 'windows') shell: bash From be55993ddac3a7586eb652d54a3a993255f626bb Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 17 Nov 2020 13:14:23 -0800 Subject: [PATCH 13/28] try removing single quotes --- .github/workflows/master_build.yml | 12 ++++++------ .github/workflows/pr_build.yml | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index 505efe0171..a09844608f 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -49,14 +49,14 @@ jobs: id: buildenv1 run: | echo "UPLOAD_PREFIX=master" >> $GITHUB_ENV - echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV - echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})`" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7" >> $GITHUB_ENV + echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=tgz" >> $GITHUB_ENV - echo "CMAKE_BUILD_EXTRA=`-- -j3`" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)`" >> $GITHUB_ENV + echo "CMAKE_BUILD_EXTRA=-- -j3" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then @@ -64,7 +64,7 @@ jobs: echo "ZIP_COMMAND=zip" >> $GITHUB_ENV echo "ZIP_ARGS=-r" >> $GITHUB_ENV echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" >> $GITHUB_ENV echo "::set-output name=symbols_archive::${BUILD_NUMBER}-${{ matrix.build_type }}-mac-symbols.zip" fi # Windows build variables @@ -73,7 +73,7 @@ jobs: echo "ZIP_COMMAND=7z" >> $GITHUB_ENV echo "ZIP_ARGS=a" >> $GITHUB_ENV echo "INSTALLER_EXT=exe" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-A x64`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-A x64" >> $GITHUB_ENV echo "SYMBOL_REGEX=\(exe\|dll\|pdb\)" >> $GITHUB_ENV echo "symbols_archive=${BUILD_NUMBER}-${{ matrix.build_type }}-win-symbols.zip" >> $GITHUB_ENV # echo "HF_PFX_PASSPHRASE=${{secrets.pfx_key}}" >> $GITHUB_ENV diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index b41304100f..5cfc566717 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -49,32 +49,32 @@ jobs: shell: bash id: buildenv1 run: | - echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV - echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})`" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7" >> $GITHUB_ENV + echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=*" >> $GITHUB_ENV - echo "CMAKE_BUILD_EXTRA=`-- -j3`" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)`" >> $GITHUB_ENV + echo "CMAKE_BUILD_EXTRA=-- -j3" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" >> $GITHUB_ENV fi # Windows build variables if [ "${{ matrix.os }}" = "windows-latest" ]; then echo "PYTHON_EXEC=python" >> $GITHUB_ENV echo "INSTALLER_EXT=exe" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-A x64`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-A x64" >> $GITHUB_ENV fi # Android + Quest build variables if [[ "${{ matrix.build_type }}" == "android" ]]; then HIFI_ANDROID_PRECOMPILED="${{runner.workspace}}/dependencies" - echo "HIFI_ANDROID_PRECOMPILED=`$HIFI_ANDROID_PRECOMPILED`" >> $GITHUB_ENV + echo "HIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED" >> $GITHUB_ENV mkdir $HIFI_ANDROID_PRECOMPILED echo "INSTALLER_EXT=apk" >> $GITHUB_ENV fi From 57729e3cef0e142054b0f21c807f550396697028 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 11:38:50 +1300 Subject: [PATCH 14/28] Remove single quotes Per commit be55993 by HifiExperiments. --- .github/workflows/pr_build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 5eb8e2a647..d0fa2b8883 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -43,27 +43,27 @@ jobs: shell: bash id: buildenv1 run: | - echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV - echo "JOB_NAME=`build (${{matrix.os}}, ${{matrix.build_type}})`" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7" >> $GITHUB_ENV + echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=*" >> $GITHUB_ENV - echo "CMAKE_BUILD_EXTRA=`-- -j3`" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)`" >> $GITHUB_ENV + echo "CMAKE_BUILD_EXTRA=-- -j3" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" >> $GITHUB_ENV fi # Windows build variables if [ "${{ matrix.os }}" = "windows-latest" ]; then echo "PYTHON_EXEC=python" >> $GITHUB_ENV echo "INSTALLER_EXT=exe" >> $GITHUB_ENV - echo "CMAKE_EXTRA=`-A x64`" >> $GITHUB_ENV + echo "CMAKE_EXTRA=-A x64" >> $GITHUB_ENV fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure Build Environment 2 From 17f579882a3a1f7a3e93e87440d84e1f4a97cd44 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 17 Nov 2020 15:09:50 -0800 Subject: [PATCH 15/28] try fixing commit short --- .github/workflows/master_build.yml | 3 ++- .github/workflows/pr_build.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index a09844608f..e264ba7937 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -49,7 +49,8 @@ jobs: id: buildenv1 run: | echo "UPLOAD_PREFIX=master" >> $GITHUB_ENV - echo "GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7" >> $GITHUB_ENV + GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7 + echo "GIT_COMMIT_SHORT=$GIT_COMMIT_SHORT" >> $GITHUB_ENV echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 5cfc566717..9907109e9c 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -49,7 +49,8 @@ jobs: shell: bash id: buildenv1 run: | - echo "GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7" >> $GITHUB_ENV + GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7 + echo "GIT_COMMIT_SHORT=$GIT_COMMIT_SHORT" >> $GITHUB_ENV echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables From c2990263783db204cc40e0e8968f8d0e4f143838 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 14:52:58 +1300 Subject: [PATCH 16/28] Calculate short SHA --- .github/workflows/pr_build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index d0fa2b8883..2558cb153c 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -43,7 +43,8 @@ jobs: shell: bash id: buildenv1 run: | - echo "GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7" >> $GITHUB_ENV + echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` + echo "GIT_COMMIT_SHORT={{github_sha_sort}}" >> $GITHUB_ENV echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables From 6c8b11dddaca9fbc86a934b2ee33d524940634f2 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 16:54:21 +1300 Subject: [PATCH 17/28] Typo --- .github/workflows/pr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 2558cb153c..a8caa1c6bd 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -44,7 +44,7 @@ jobs: id: buildenv1 run: | echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` - echo "GIT_COMMIT_SHORT={{github_sha_sort}}" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT={{github_sha_short}}" >> $GITHUB_ENV echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables From 066dd2a6cc695713c4ab48c564e952679e04a733 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 20:49:47 +1300 Subject: [PATCH 18/28] Typo --- .github/workflows/pr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index a8caa1c6bd..1e8b7e53ad 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -44,7 +44,7 @@ jobs: id: buildenv1 run: | echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` - echo "GIT_COMMIT_SHORT={{github_sha_short}}" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=${{github_sha_short}}" >> $GITHUB_ENV echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables From ea77db85d3734ab18a28b574f0217540303b5996 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 21:06:29 +1300 Subject: [PATCH 19/28] Use output var in second step --- .github/workflows/pr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 1e8b7e53ad..d975957d55 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -44,7 +44,6 @@ jobs: id: buildenv1 run: | echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` - echo "GIT_COMMIT_SHORT=${{github_sha_short}}" >> $GITHUB_ENV echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables @@ -73,7 +72,8 @@ jobs: echo "${{ steps.buildenv1.outputs.symbols_archive }}" echo "ARTIFACT_PATTERN=Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables - echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=${{github_sha_short}}" >> $GITHUB_ENV + echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-${{ github_sha_short }}.$INSTALLER_EXT" >> $GITHUB_ENV - name: Clear Working Directory if: startsWith(matrix.os, 'windows') shell: bash From e8520becd6dce9fad55111713b7315b8c9162e04 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Nov 2020 21:11:48 +1300 Subject: [PATCH 20/28] Syntax --- .github/workflows/pr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index d975957d55..d1662e5c8e 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -72,8 +72,8 @@ jobs: echo "${{ steps.buildenv1.outputs.symbols_archive }}" echo "ARTIFACT_PATTERN=Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables - echo "GIT_COMMIT_SHORT=${{github_sha_short}}" >> $GITHUB_ENV - echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-${{ github_sha_short }}.$INSTALLER_EXT" >> $GITHUB_ENV + echo "GIT_COMMIT_SHORT=${{ steps.buildenv1.outputs.github_sha_short }}" >> $GITHUB_ENV + echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-${{ steps.buildenv1.outputs.github_sha_short }}.$INSTALLER_EXT" >> $GITHUB_ENV - name: Clear Working Directory if: startsWith(matrix.os, 'windows') shell: bash From 1e07971d10ae43089b9eea0d9c0044e72109ac86 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 17 Nov 2020 18:53:24 -0800 Subject: [PATCH 21/28] how about this --- .github/workflows/master_build.yml | 4 ++-- .github/workflows/pr_build.yml | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index e264ba7937..6d23257899 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -49,8 +49,7 @@ jobs: id: buildenv1 run: | echo "UPLOAD_PREFIX=master" >> $GITHUB_ENV - GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7 - echo "GIT_COMMIT_SHORT=$GIT_COMMIT_SHORT" >> $GITHUB_ENV + echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "ubuntu-"* ]]; then @@ -87,6 +86,7 @@ jobs: echo "${{ steps.buildenv1.outputs.symbols_archive }}" echo "ARTIFACT_PATTERN=Vircadia-Alpha-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables + echo "GIT_COMMIT_SHORT=${{ steps.buildenv1.outputs.github_sha_short }}" >> $GITHUB_ENV if [ "${{ matrix.build_type }}" = "full" ]; then echo "CLIENT_ONLY=FALSE" >> $GITHUB_ENV echo "INSTALLER=Vircadia-Alpha-$BUILD_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 9907109e9c..757a6fd7c8 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -22,7 +22,6 @@ env: # WIN32 specific variables PreferredToolArchitecture: X64 - GIT_COMMIT_SHORT: ${{ github.sha }} jobs: @@ -49,8 +48,7 @@ jobs: shell: bash id: buildenv1 run: | - GIT_COMMIT_SHORT=echo $GIT_COMMIT | cut -c1-7 - echo "GIT_COMMIT_SHORT=$GIT_COMMIT_SHORT" >> $GITHUB_ENV + echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $GITHUB_ENV # Linux build variables @@ -84,6 +82,7 @@ jobs: shell: bash run: | echo "${{ steps.buildenv1.outputs.symbols_archive }}" + echo "GIT_COMMIT_SHORT=${{ steps.buildenv1.outputs.github_sha_short }}" >> $GITHUB_ENV if [[ "${{ matrix.build_type }}" != "android" ]]; then echo "ARTIFACT_PATTERN=Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables From 031b3985b03bf120fff8cb1822d0db34f77a94fa Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Wed, 18 Nov 2020 23:14:34 -0500 Subject: [PATCH 22/28] Fix for Issue 869 This excludes the local and avatar entities from what is returns by Entities.getChildrenIDs to avoid the selection tools of the Zone entities to be considered as Children of it. This was necessary for the display of the hierarchy status, but also for the "Add Children to Selection". --- scripts/system/create/edit.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 099cb94988..a8b829c551 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -2908,7 +2908,7 @@ function zoneSortOrder(a, b) { function getParentState(id) { var state = "NONE"; var properties = Entities.getEntityProperties(id, ["parentID"]); - var children = Entities.getChildrenIDs(id); + var children = getDomainOnlyChildrenIDs(id); if (properties.parentID !== Uuid.NULL) { if (children.length > 0) { state = "PARENT_CHILDREN"; @@ -2923,4 +2923,17 @@ function getParentState(id) { return state; } +function getDomainOnlyChildrenIDs(id) { + var allChildren = Entities.getChildrenIDs(id); + var domainOnlyChildren = []; + var properties; + for (var i = 0; i < allChildren.length; i++) { + properties = Entities.getEntityProperties(allChildren[i], ["entityHostType"]); + if (properties.entityHostType == "domain") { + domainOnlyChildren.push(allChildren[i]); + } + } + return domainOnlyChildren; +} + }()); // END LOCAL_SCOPE From 22abf1c2c47aca06e7637b4a3aea48b9b4e26115 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Wed, 18 Nov 2020 23:15:23 -0500 Subject: [PATCH 23/28] Fix for Issue 869 This excludes the local and avatar entities from what is returns by Entities.getChildrenIDs to avoid the selection tools of the Zone entities to be considered as Children of it. This was necessary for the display of the hierarchy status, but also for the "Add Children to Selection". --- .../create/entitySelectionTool/entitySelectionTool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/system/create/entitySelectionTool/entitySelectionTool.js b/scripts/system/create/entitySelectionTool/entitySelectionTool.js index 71edbde765..f9a30ef6a5 100644 --- a/scripts/system/create/entitySelectionTool/entitySelectionTool.js +++ b/scripts/system/create/entitySelectionTool/entitySelectionTool.js @@ -724,12 +724,12 @@ SelectionManager = (function() { that.addChildrenToSelection = function() { if (that.hasSelection()) { for (var i = 0; i < that.selections.length; i++) { - var childrenIDs = Entities.getChildrenIDs(that.selections[i]); - var collectNewChildren; + var childrenIDs = getDomainOnlyChildrenIDs(that.selections[i]); + var collectNewChildren; var j; var k = 0; do { - collectNewChildren = Entities.getChildrenIDs(childrenIDs[k]); + collectNewChildren = getDomainOnlyChildrenIDs(childrenIDs[k]); if (collectNewChildren.length > 0) { for (j = 0; j < collectNewChildren.length; j++) { childrenIDs.push(collectNewChildren[j]); @@ -746,7 +746,7 @@ SelectionManager = (function() { that._update(true, this); } else { audioFeedback.rejection(); - Window.notifyEditError("You have nothing selected."); + Window.notifyEditError("You have nothing selected."); } }; @@ -832,7 +832,7 @@ SelectionDisplay = (function() { const BOUNDING_EDGE_OFFSET = 0.5; - const DUPLICATOR_OFFSET = { x: 0.6, y: 0, z: 0.6 }; + const DUPLICATOR_OFFSET = { x: 0.6, y: 0, z: 0.6 }; const CTRL_KEY_CODE = 16777249; From 00575ae8f88c40f67679277cbdbe6fc8cc8f5996 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:43:12 -0500 Subject: [PATCH 24/28] Excluding EntityShapeVisualizer from Children list Excluding EntityShapeVisualizer from Children list Now a name is given to the EntityShape of the EntityShapeVisualizer (used to display the zone) so we can now exclude them from the children list when it's time to figure if there are children for an entity. (This is a better approach than excluding al the local entities) The name has been used because it gives better results than trying to use the id map that arrive always too late. The name is unique for a session, it includes a UUID. --- scripts/system/create/edit.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index a8b829c551..3c6f43d3a1 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -117,8 +117,10 @@ var gridTool = new GridTool({ }); gridTool.setVisible(false); +var entityShapeVisualizerSessionName = "SHAPE_VISUALIZER_" + Uuid.generate(); + var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js'); -var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"]); +var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"], entityShapeVisualizerSessionName); var entityListTool = new EntityListTool(shouldUseEditTabletApp); @@ -2925,15 +2927,15 @@ function getParentState(id) { function getDomainOnlyChildrenIDs(id) { var allChildren = Entities.getChildrenIDs(id); - var domainOnlyChildren = []; + var realChildren = []; var properties; for (var i = 0; i < allChildren.length; i++) { - properties = Entities.getEntityProperties(allChildren[i], ["entityHostType"]); - if (properties.entityHostType == "domain") { - domainOnlyChildren.push(allChildren[i]); + properties = Entities.getEntityProperties(allChildren[i], ["name"]); + if (properties.name !== entityShapeVisualizerSessionName && properties.name !== undefined) { + realChildren.push(allChildren[i]); } } - return domainOnlyChildren; + return realChildren; } }()); // END LOCAL_SCOPE From b633bc4a164ecfa44ce7b063b5bf2e676d2b4672 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:44:15 -0500 Subject: [PATCH 25/28] Excluding EntityShapeVisualizer from Children list Excluding EntityShapeVisualizer from Children list Now a name is given to the EntityShape of the EntityShapeVisualizer (used to display the zone) so we can now exclude them from the children list when it's time to figure if there are children for an entity. (This is a better approach than excluding al the local entities) The name has been used because it gives better results than trying to use the id map that arrive always too late. The name is unique for a session, it includes a UUID. --- .../system/create/modules/entityShapeVisualizer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/system/create/modules/entityShapeVisualizer.js b/scripts/system/create/modules/entityShapeVisualizer.js index dbf09a1cb7..45cf68fdb5 100644 --- a/scripts/system/create/modules/entityShapeVisualizer.js +++ b/scripts/system/create/modules/entityShapeVisualizer.js @@ -116,12 +116,14 @@ function deepCopy(v) { return JSON.parse(JSON.stringify(v)); } -function EntityShape(entityID) { +function EntityShape(entityID, entityShapeVisualizerSessionName) { this.entityID = entityID; + this.entityShapeVisualizerSessionName = entityShapeVisualizerSessionName; + var propertiesForType = getEntityShapePropertiesForType(Entities.getEntityProperties(entityID, REQUESTED_ENTITY_SHAPE_PROPERTIES)); this.previousPropertiesForType = propertiesForType; - + this.initialize(propertiesForType); } @@ -130,6 +132,7 @@ EntityShape.prototype = { // Create new instance of JS object: var overlayProperties = deepCopy(properties); + overlayProperties.name = this.entityShapeVisualizerSessionName; overlayProperties.localPosition = Vec3.ZERO; overlayProperties.localRotation = Quat.IDENTITY; overlayProperties.canCastShadows = false; @@ -172,11 +175,11 @@ EntityShape.prototype = { } }; -function EntityShapeVisualizer(visualizedTypes) { +function EntityShapeVisualizer(visualizedTypes, entityShapeVisualizerSessionName) { this.acceptedEntities = []; this.ignoredEntities = []; this.entityShapes = {}; - + this.entityShapeVisualizerSessionName = entityShapeVisualizerSessionName; this.visualizedTypes = visualizedTypes; } @@ -185,7 +188,7 @@ EntityShapeVisualizer.prototype = { if (this.entityShapes[entityID]) { return; } - this.entityShapes[entityID] = new EntityShape(entityID); + this.entityShapes[entityID] = new EntityShape(entityID, this.entityShapeVisualizerSessionName); }, updateEntity: function(entityID) { From c4092a35e34547edd706de4c8a5b3cd6377b181e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 22 Nov 2020 14:08:36 +1300 Subject: [PATCH 26/28] Fix GHA master build target branch --- .github/workflows/master_build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index 824c279845..d6e4f648c5 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -3,8 +3,7 @@ name: Master CI Build on: push: branches: - - gha-master-ci -# FIXME: Change target branch to "master" before merging into "master" branch. + - master env: APP_NAME: interface From 343ded8c6f9cea43e1570e31d50c531ee18307e8 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 21 Nov 2020 22:02:49 -0500 Subject: [PATCH 27/28] Minor code adjustments Minor code adjustments --- scripts/system/create/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 3c6f43d3a1..bc7afd8dc3 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -2931,7 +2931,7 @@ function getDomainOnlyChildrenIDs(id) { var properties; for (var i = 0; i < allChildren.length; i++) { properties = Entities.getEntityProperties(allChildren[i], ["name"]); - if (properties.name !== entityShapeVisualizerSessionName && properties.name !== undefined) { + if (properties.name !== undefined && properties.name !== entityShapeVisualizerSessionName) { realChildren.push(allChildren[i]); } } From 182302c3e75014ead9de65986139d088185b9606 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 28 Nov 2020 02:07:08 +0100 Subject: [PATCH 28/28] GL_TEXTURE_FREE_MEMORY_ATI returns 4 values, not just 1 This should fix a buffer overflow that happens on ATI cards. --- libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index ef247b0835..38aca093cd 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -219,19 +219,21 @@ void GLBackend::init() { } size_t GLBackend::getAvailableMemory() { - GLint mem; + // GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX returns 1 value + // GL_TEXTURE_FREE_MEMORY_ATI returns 4 values, we only need the first + GLint mem[4] = {0,0,0,0}; switch( _videoCard ) { case NVIDIA: #if !defined(Q_OS_ANDROID) - glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem); + glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem[0]); #endif - return mem * BYTES_PER_KIB; + return mem[0] * BYTES_PER_KIB; case ATI: #if !defined(Q_OS_ANDROID) - glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem); + glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem[0]); #endif - return mem * BYTES_PER_KIB; + return mem[0] * BYTES_PER_KIB; case MESA: return 0; // Don't know the current value case Unknown: @@ -1002,4 +1004,4 @@ void GLBackend::setCameraCorrection(const Mat4& correction, const Mat4& prevRend void GLBackend::syncProgram(const gpu::ShaderPointer& program) { gpu::gl::GLShader::sync(*this, *program); -} \ No newline at end of file +}