diff --git a/apps/paper/ios/paper.xcodeproj/project.pbxproj b/apps/paper/ios/paper.xcodeproj/project.pbxproj index ea31a8a210..c4d549913c 100644 --- a/apps/paper/ios/paper.xcodeproj/project.pbxproj +++ b/apps/paper/ios/paper.xcodeproj/project.pbxproj @@ -12,9 +12,9 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 5A5573D48597F250071C3631 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = C4E88CA904DA354414CAB50C /* PrivacyInfo.xcprivacy */; }; - 7FEC58A8FD2A3EDFB5750E2C /* libPods-paper-paperTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E9B7928C62E960FC3CAE89C1 /* libPods-paper-paperTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; - ED38CE2BF27068459A24ECF7 /* libPods-paper.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C64031E821E865DDC6458BA /* libPods-paper.a */; }; + BF3C3E25CA809A9BF718A4CA /* libPods-paper-paperTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A59642577DCBB3519F208CA3 /* libPods-paper-paperTests.a */; }; + E94A991220163D81CB0F9CA5 /* libPods-paper.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAA39124FDB9D7AC209AD47D /* libPods-paper.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -38,15 +38,15 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = paper/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = paper/main.m; sourceTree = ""; }; 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = paper/PrivacyInfo.xcprivacy; sourceTree = ""; }; - 2B0BB7705762AB0CCCFA5CDC /* Pods-paper.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper.release.xcconfig"; path = "Target Support Files/Pods-paper/Pods-paper.release.xcconfig"; sourceTree = ""; }; - 3488FD118FCD4EB338114AAA /* Pods-paper-paperTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper-paperTests.debug.xcconfig"; path = "Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests.debug.xcconfig"; sourceTree = ""; }; - 4C64031E821E865DDC6458BA /* libPods-paper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-paper.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = paper/LaunchScreen.storyboard; sourceTree = ""; }; - 852870306A24801FBCD463D2 /* Pods-paper-paperTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper-paperTests.release.xcconfig"; path = "Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests.release.xcconfig"; sourceTree = ""; }; - 9DF30D641329E20B50BBFA4E /* Pods-paper.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper.debug.xcconfig"; path = "Target Support Files/Pods-paper/Pods-paper.debug.xcconfig"; sourceTree = ""; }; + 9B406492AEBB2E5B3C2747D3 /* Pods-paper.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper.release.xcconfig"; path = "Target Support Files/Pods-paper/Pods-paper.release.xcconfig"; sourceTree = ""; }; + A59642577DCBB3519F208CA3 /* libPods-paper-paperTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-paper-paperTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C4E88CA904DA354414CAB50C /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = paper/PrivacyInfo.xcprivacy; sourceTree = ""; }; - E9B7928C62E960FC3CAE89C1 /* libPods-paper-paperTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-paper-paperTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + D5AAD725C2F03980E26BF3FC /* Pods-paper.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper.debug.xcconfig"; path = "Target Support Files/Pods-paper/Pods-paper.debug.xcconfig"; sourceTree = ""; }; + D64D99ADC56E2B77172656F1 /* Pods-paper-paperTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper-paperTests.release.xcconfig"; path = "Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests.release.xcconfig"; sourceTree = ""; }; + DAA39124FDB9D7AC209AD47D /* libPods-paper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-paper.a"; sourceTree = BUILT_PRODUCTS_DIR; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; + F490EE2207A8E47F8BCE06C5 /* Pods-paper-paperTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paper-paperTests.debug.xcconfig"; path = "Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,7 +54,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7FEC58A8FD2A3EDFB5750E2C /* libPods-paper-paperTests.a in Frameworks */, + BF3C3E25CA809A9BF718A4CA /* libPods-paper-paperTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -62,7 +62,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - ED38CE2BF27068459A24ECF7 /* libPods-paper.a in Frameworks */, + E94A991220163D81CB0F9CA5 /* libPods-paper.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -105,8 +105,8 @@ isa = PBXGroup; children = ( ED297162215061F000B7C4FE /* JavaScriptCore.framework */, - 4C64031E821E865DDC6458BA /* libPods-paper.a */, - E9B7928C62E960FC3CAE89C1 /* libPods-paper-paperTests.a */, + DAA39124FDB9D7AC209AD47D /* libPods-paper.a */, + A59642577DCBB3519F208CA3 /* libPods-paper-paperTests.a */, ); name = Frameworks; sourceTree = ""; @@ -145,10 +145,10 @@ BBD78D7AC51CEA395F1C20DB /* Pods */ = { isa = PBXGroup; children = ( - 9DF30D641329E20B50BBFA4E /* Pods-paper.debug.xcconfig */, - 2B0BB7705762AB0CCCFA5CDC /* Pods-paper.release.xcconfig */, - 3488FD118FCD4EB338114AAA /* Pods-paper-paperTests.debug.xcconfig */, - 852870306A24801FBCD463D2 /* Pods-paper-paperTests.release.xcconfig */, + D5AAD725C2F03980E26BF3FC /* Pods-paper.debug.xcconfig */, + 9B406492AEBB2E5B3C2747D3 /* Pods-paper.release.xcconfig */, + F490EE2207A8E47F8BCE06C5 /* Pods-paper-paperTests.debug.xcconfig */, + D64D99ADC56E2B77172656F1 /* Pods-paper-paperTests.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -160,12 +160,12 @@ isa = PBXNativeTarget; buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "paperTests" */; buildPhases = ( - 4F79718F1BEE1F6FE3619B51 /* [CP] Check Pods Manifest.lock */, + 2FBA9C06365FE92618A0A891 /* [CP] Check Pods Manifest.lock */, 00E356EA1AD99517003FC87E /* Sources */, 00E356EB1AD99517003FC87E /* Frameworks */, 00E356EC1AD99517003FC87E /* Resources */, - 5720DCE66AA6CBC01508F8A5 /* [CP] Embed Pods Frameworks */, - 57BD29C564BCC30858545D68 /* [CP] Copy Pods Resources */, + C0A900717973420963FA7DA4 /* [CP] Embed Pods Frameworks */, + 14DBEAAC662297C77820AD82 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -181,13 +181,13 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "paper" */; buildPhases = ( - 3F7BE6E00CB025D3580B5F67 /* [CP] Check Pods Manifest.lock */, + F9CCADD64ADDF6C2E16DD898 /* [CP] Check Pods Manifest.lock */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - 64B7EEAB0D36F7B8420933FE /* [CP] Embed Pods Frameworks */, - DD6A5382C464C81023CC20D0 /* [CP] Copy Pods Resources */, + A8CC64B35C9FEB70F3FB46AE /* [CP] Embed Pods Frameworks */, + 0579A6AB09836D6BB149EF96 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -271,116 +271,116 @@ shellPath = /bin/sh; shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; }; - 3F7BE6E00CB025D3580B5F67 /* [CP] Check Pods Manifest.lock */ = { + 0579A6AB09836D6BB149EF96 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-resources-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-paper-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 4F79718F1BEE1F6FE3619B51 /* [CP] Check Pods Manifest.lock */ = { + 14DBEAAC662297C77820AD82 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-resources-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-paper-paperTests-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 5720DCE66AA6CBC01508F8A5 /* [CP] Embed Pods Frameworks */ = { + 2FBA9C06365FE92618A0A891 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-paper-paperTests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 57BD29C564BCC30858545D68 /* [CP] Copy Pods Resources */ = { + A8CC64B35C9FEB70F3FB46AE /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 64B7EEAB0D36F7B8420933FE /* [CP] Embed Pods Frameworks */ = { + C0A900717973420963FA7DA4 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-frameworks-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-frameworks-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper-paperTests/Pods-paper-paperTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - DD6A5382C464C81023CC20D0 /* [CP] Copy Pods Resources */ = { + F9CCADD64ADDF6C2E16DD898 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-resources-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Copy Pods Resources"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-paper-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-paper/Pods-paper-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -416,7 +416,7 @@ /* Begin XCBuildConfiguration section */ 00E356F61AD99517003FC87E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3488FD118FCD4EB338114AAA /* Pods-paper-paperTests.debug.xcconfig */; + baseConfigurationReference = F490EE2207A8E47F8BCE06C5 /* Pods-paper-paperTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -443,7 +443,7 @@ }; 00E356F71AD99517003FC87E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 852870306A24801FBCD463D2 /* Pods-paper-paperTests.release.xcconfig */; + baseConfigurationReference = D64D99ADC56E2B77172656F1 /* Pods-paper-paperTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; @@ -467,7 +467,7 @@ }; 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9DF30D641329E20B50BBFA4E /* Pods-paper.debug.xcconfig */; + baseConfigurationReference = D5AAD725C2F03980E26BF3FC /* Pods-paper.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; @@ -494,7 +494,7 @@ }; 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2B0BB7705762AB0CCCFA5CDC /* Pods-paper.release.xcconfig */; + baseConfigurationReference = 9B406492AEBB2E5B3C2747D3 /* Pods-paper.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; diff --git a/packages/skia/android/CMakeLists.txt b/packages/skia/android/CMakeLists.txt index 553cc54c31..168c5f472f 100644 --- a/packages/skia/android/CMakeLists.txt +++ b/packages/skia/android/CMakeLists.txt @@ -87,7 +87,6 @@ add_library( "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp" "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDomView.cpp" - "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDispatchQueue.cpp" "${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base/DrawingContext.cpp" "${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base/ConcatablePaint.cpp" diff --git a/packages/skia/android/cpp/jni/JniPlatformContext.cpp b/packages/skia/android/cpp/jni/JniPlatformContext.cpp index ba3e70e0c9..2ef8a9767a 100644 --- a/packages/skia/android/cpp/jni/JniPlatformContext.cpp +++ b/packages/skia/android/cpp/jni/JniPlatformContext.cpp @@ -63,10 +63,6 @@ using TSelf = jni::local_ref; void JniPlatformContext::registerNatives() { registerHybrid({ makeNativeMethod("initHybrid", JniPlatformContext::initHybrid), - makeNativeMethod("notifyDrawLoop", - JniPlatformContext::notifyDrawLoopExternal), - makeNativeMethod("notifyTaskReady", - JniPlatformContext::notifyTaskReadyExternal), }); } @@ -134,51 +130,6 @@ sk_sp JniPlatformContext::takeScreenshotFromViewTag(size_t tag) { return skImage; } -void JniPlatformContext::startDrawLoop() { - jni::ThreadScope ts; - // Start drawing loop - static auto method = - javaPart_->getClass()->getMethod("beginDrawLoop"); - method(javaPart_.get()); -} - -void JniPlatformContext::stopDrawLoop() { - jni::ThreadScope ts; - // Stop drawing loop - static auto method = - javaPart_->getClass()->getMethod("endDrawLoop"); - method(javaPart_.get()); -} - -void JniPlatformContext::notifyDrawLoopExternal() { - jni::ThreadScope ts; - _onNotifyDrawLoop(); -} - -void JniPlatformContext::runTaskOnMainThread(std::function task) { - _taskMutex->lock(); - _taskCallbacks.push(task); - _taskMutex->unlock(); - - // Notify Java that task is ready - static auto method = javaPart_->getClass()->getMethod( - "notifyTaskReadyOnMainThread"); - method(javaPart_.get()); -} - -void JniPlatformContext::notifyTaskReadyExternal() { - jni::ThreadScope ts; - _taskMutex->lock(); - auto task = _taskCallbacks.front(); - if (task != nullptr) { - _taskCallbacks.pop(); - _taskMutex->unlock(); - task(); - } else { - _taskMutex->unlock(); - } -} - void JniPlatformContext::performStreamOperation( const std::string &sourceUri, const std::function)> &op) { diff --git a/packages/skia/android/cpp/jni/include/JniPlatformContext.h b/packages/skia/android/cpp/jni/include/JniPlatformContext.h index 634e891d07..99a33e48b9 100644 --- a/packages/skia/android/cpp/jni/include/JniPlatformContext.h +++ b/packages/skia/android/cpp/jni/include/JniPlatformContext.h @@ -33,11 +33,6 @@ class JniPlatformContext : public jni::HybridClass { void raiseError(const std::exception &err); - void startDrawLoop(); - void stopDrawLoop(); - - void notifyDrawLoopExternal(); - void notifyTaskReadyExternal(); void runTaskOnMainThread(std::function task); @@ -46,10 +41,6 @@ class JniPlatformContext : public jni::HybridClass { sk_sp takeScreenshotFromViewTag(size_t tag); - void setOnNotifyDrawLoop(const std::function &callback) { - _onNotifyDrawLoop = callback; - } - jni::global_ref createVideo(const std::string &url); private: @@ -58,16 +49,9 @@ class JniPlatformContext : public jni::HybridClass { float _pixelDensity; - std::function _onNotifyDrawLoop; - - std::queue> _taskCallbacks; - - std::shared_ptr _taskMutex; - explicit JniPlatformContext( jni::alias_ref jThis, const float pixelDensity) - : _taskMutex(std::make_shared()), - javaPart_(jni::make_global(jThis)), _pixelDensity(pixelDensity) {} + : javaPart_(jni::make_global(jThis)), _pixelDensity(pixelDensity) {} }; } // namespace RNSkia \ No newline at end of file diff --git a/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h b/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h index 7985d62be7..5a4bab2fa6 100644 --- a/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h +++ b/packages/skia/android/cpp/jni/include/JniSkiaBaseView.h @@ -39,8 +39,6 @@ class JniSkiaBaseView { virtual void surfaceDestroyed() { _skiaAndroidView->surfaceDestroyed(); } - virtual void setMode(std::string mode) { _skiaAndroidView->setMode(mode); } - virtual void setDebugMode(bool show) { _skiaAndroidView->setShowDebugInfo(show); } diff --git a/packages/skia/android/cpp/jni/include/JniSkiaDomView.h b/packages/skia/android/cpp/jni/include/JniSkiaDomView.h index 3820dd4c3b..c675e098d8 100644 --- a/packages/skia/android/cpp/jni/include/JniSkiaDomView.h +++ b/packages/skia/android/cpp/jni/include/JniSkiaDomView.h @@ -40,7 +40,6 @@ class JniSkiaDomView : public jni::HybridClass, makeNativeMethod("surfaceDestroyed", JniSkiaDomView::surfaceDestroyed), makeNativeMethod("surfaceSizeChanged", JniSkiaDomView::surfaceSizeChanged), - makeNativeMethod("setMode", JniSkiaDomView::setMode), makeNativeMethod("setDebugMode", JniSkiaDomView::setDebugMode), makeNativeMethod("registerView", JniSkiaDomView::registerView), makeNativeMethod("unregisterView", JniSkiaDomView::unregisterView)}); @@ -57,8 +56,6 @@ class JniSkiaDomView : public jni::HybridClass, void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); } - void setMode(std::string mode) override { JniSkiaBaseView::setMode(mode); } - void setDebugMode(bool show) override { JniSkiaBaseView::setDebugMode(show); } void registerView(int nativeId) override { diff --git a/packages/skia/android/cpp/jni/include/JniSkiaManager.h b/packages/skia/android/cpp/jni/include/JniSkiaManager.h index b0af672dfc..1f384a5465 100644 --- a/packages/skia/android/cpp/jni/include/JniSkiaManager.h +++ b/packages/skia/android/cpp/jni/include/JniSkiaManager.h @@ -53,8 +53,6 @@ class JniSkiaManager : public jni::HybridClass { std::shared_ptr getSkiaManager() { return _skManager; } void invalidate() { - _context->stopDrawLoop(); - _context->notifyDrawLoop(true); _skManager = nullptr; _context = nullptr; } diff --git a/packages/skia/android/cpp/jni/include/JniSkiaPictureView.h b/packages/skia/android/cpp/jni/include/JniSkiaPictureView.h index f756d32ca2..a55cd324a3 100644 --- a/packages/skia/android/cpp/jni/include/JniSkiaPictureView.h +++ b/packages/skia/android/cpp/jni/include/JniSkiaPictureView.h @@ -41,7 +41,6 @@ class JniSkiaPictureView : public jni::HybridClass, JniSkiaPictureView::surfaceDestroyed), makeNativeMethod("surfaceSizeChanged", JniSkiaPictureView::surfaceSizeChanged), - makeNativeMethod("setMode", JniSkiaPictureView::setMode), makeNativeMethod("setDebugMode", JniSkiaPictureView::setDebugMode), makeNativeMethod("registerView", JniSkiaPictureView::registerView), makeNativeMethod("unregisterView", @@ -59,8 +58,6 @@ class JniSkiaPictureView : public jni::HybridClass, void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); } - void setMode(std::string mode) override { JniSkiaBaseView::setMode(mode); } - void setDebugMode(bool show) override { JniSkiaBaseView::setDebugMode(show); } void registerView(int nativeId) override { diff --git a/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h b/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h new file mode 100644 index 0000000000..0f82f47e4c --- /dev/null +++ b/packages/skia/android/cpp/rnskia-android/MainThreadDispatcher.h @@ -0,0 +1,69 @@ +#pragma once + +#include +#include + +class MainThreadDispatcher { +private: + ALooper *mainLooper; + int messagePipe[2]; + std::queue> taskQueue; + std::mutex queueMutex; + + static constexpr int LOOPER_ID_MAIN = 1; + + void processMessages() { + std::lock_guard lock(queueMutex); + while (!taskQueue.empty()) { + auto task = taskQueue.front(); + taskQueue.pop(); + task(); + } + } + +public: + static MainThreadDispatcher &getInstance() { + static MainThreadDispatcher instance; + return instance; + } + + void post(std::function task) { + // TODO: this is disabled for now but we can clean this up + // if (ALooper_forThread() == mainLooper) { + // task(); + // } else { + { + std::lock_guard lock(queueMutex); + taskQueue.push(std::move(task)); + } + char wake = 1; + write(messagePipe[1], &wake, 1); + // } + } + + ~MainThreadDispatcher() { + close(messagePipe[0]); + close(messagePipe[1]); + } + +private: + MainThreadDispatcher() { + mainLooper = ALooper_forThread(); + if (!mainLooper) { + mainLooper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + } + + pipe(messagePipe); + + ALooper_addFd( + mainLooper, messagePipe[0], LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, + [](int fd, int events, void *data) -> int { + char buf[1]; + read(fd, buf, 1); + auto dispatcher = static_cast(data); + dispatcher->processMessages(); + return 1; + }, + this); + } +}; \ No newline at end of file diff --git a/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h b/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h index 415ccd5b87..d8f71eeae0 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +++ b/packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h @@ -17,6 +17,7 @@ #include "AHardwareBufferUtils.h" #include "JniPlatformContext.h" +#include "MainThreadDispatcher.h" #include "RNSkAndroidVideo.h" #include "RNSkPlatformContext.h" @@ -37,13 +38,9 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { std::shared_ptr jsCallInvoker) : RNSkPlatformContext(runtime, jsCallInvoker, jniPlatformContext->getPixelDensity()), - _jniPlatformContext(jniPlatformContext) { - // Hook onto the notify draw loop callback in the platform context - jniPlatformContext->setOnNotifyDrawLoop( - [this]() { notifyDrawLoop(false); }); - } + _jniPlatformContext(jniPlatformContext) {} - ~RNSkAndroidPlatformContext() { stopDrawLoop(); } + ~RNSkAndroidPlatformContext() {} void performStreamOperation( const std::string &sourceUri, @@ -163,17 +160,13 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { } void runOnMainThread(std::function task) override { - _jniPlatformContext->runTaskOnMainThread(task); + MainThreadDispatcher::getInstance().post(std::move(task)); } sk_sp takeScreenshotFromViewTag(size_t tag) override { return _jniPlatformContext->takeScreenshotFromViewTag(tag); } - void startDrawLoop() override { _jniPlatformContext->startDrawLoop(); } - - void stopDrawLoop() override { _jniPlatformContext->stopDrawLoop(); } - private: JniPlatformContext *_jniPlatformContext; }; diff --git a/packages/skia/android/cpp/rnskia-android/RNSkAndroidView.h b/packages/skia/android/cpp/rnskia-android/RNSkAndroidView.h index f1e40c1f59..e209a78bc9 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkAndroidView.h +++ b/packages/skia/android/cpp/rnskia-android/RNSkAndroidView.h @@ -19,8 +19,6 @@ class RNSkBaseAndroidView { virtual float getPixelDensity() = 0; - virtual void setMode(std::string mode) = 0; - virtual void setShowDebugInfo(bool show) = 0; virtual void viewDidUnmount() = 0; @@ -42,7 +40,7 @@ class RNSkAndroidView : public T, public RNSkBaseAndroidView { // Try to render directly when the surface has been set so that // we don't have to wait until the draw loop returns. - RNSkView::renderImmediate(); + RNSkView::redraw(); } void surfaceDestroyed() override { @@ -55,24 +53,16 @@ class RNSkAndroidView : public T, public RNSkBaseAndroidView { ->surfaceSizeChanged(surface, width, height); // This is only need for the first time to frame, this renderImmediate call // will invoke updateTexImage for the previous frame - RNSkView::renderImmediate(); + RNSkView::redraw(); } float getPixelDensity() override { return T::getPlatformContext()->getPixelDensity(); } - void setMode(std::string mode) override { - if (mode.compare("continuous") == 0) { - T::setDrawingMode(RNSkDrawingMode::Continuous); - } else { - T::setDrawingMode(RNSkDrawingMode::Default); - } - } - void setShowDebugInfo(bool show) override { T::setShowDebugOverlays(show); } - void viewDidUnmount() override { T::endDrawingLoop(); } + void viewDidUnmount() override {} std::shared_ptr getSkiaView() override { return T::shared_from_this(); diff --git a/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp b/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp index 48d1e497bb..c3c587f70f 100644 --- a/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +++ b/packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp @@ -64,7 +64,6 @@ bool RNSkOpenGLCanvasProvider::renderToCanvas( // Swap buffers and show on screen _surfaceHolder->present(); - return true; } else { // the render context did not provide a surface diff --git a/packages/skia/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java b/packages/skia/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java index 0dfdfd13d6..62fa75d6c5 100644 --- a/packages/skia/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +++ b/packages/skia/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java @@ -25,14 +25,8 @@ public class PlatformContext { private final ReactContext mContext; - private boolean _drawLoopActive = false; - private boolean _isPaused = false; - private final String TAG = "PlatformContext"; - private final Handler mainHandler = new Handler(Looper.getMainLooper()); - - public PlatformContext(ReactContext reactContext) { mContext = reactContext; mHybridData = initHybrid(reactContext.getResources().getDisplayMetrics().density); @@ -53,69 +47,11 @@ private byte[] getStreamAsBytes(InputStream is) throws IOException { return buffer.toByteArray(); } - private void postFrameLoop() { - Choreographer.FrameCallback frameCallback = new Choreographer.FrameCallback() { - @Override - public void doFrame(long frameTimeNanos) { - if (_drawLoopActive) { - Choreographer.getInstance().postFrameCallback(this); - } - if (_isPaused) { - return; - } - notifyDrawLoop(); - } - }; - Choreographer.getInstance().postFrameCallback(frameCallback); - } - - - @DoNotStrip - public void notifyTaskReadyOnMainThread() { - mainHandler.post(new Runnable() { - @Override - public void run() { - notifyTaskReady(); - } - }); - } - @DoNotStrip Object takeScreenshotFromViewTag(int tag) { return ViewScreenshotService.makeViewScreenshotFromTag(mContext, tag); } - @DoNotStrip - public void raise(final String message) { - mainHandler.post(new Runnable() { - @Override - public void run() { - mContext.handleException(new Exception(message)); - } - }); - } - - @DoNotStrip - public void beginDrawLoop() { - if (_drawLoopActive) { - return; - } - _drawLoopActive = true; - mainHandler.post(new Runnable() { - @Override - public void run() { - postFrameLoop(); - } - }); - } - - @DoNotStrip - public void endDrawLoop() { - if (_drawLoopActive) { - _drawLoopActive = false; - } - } - @DoNotStrip public byte[] getJniStreamFromSource(String sourceUri) throws IOException { // First try loading the input as a resource directly @@ -163,25 +99,6 @@ public byte[] getJniStreamFromSource(String sourceUri) throws IOException { return null; } - void onPause() { - Log.i(TAG, "Paused"); - _isPaused = true; - } - - void onResume() { - _isPaused = false; - Log.i(TAG, "Resume"); - if(_drawLoopActive) { - // Restart draw loop - mainHandler.post(new Runnable() { - @Override - public void run() { - postFrameLoop(); - } - }); - } - } - @Override protected void finalize() throws Throwable { mHybridData.resetNative(); @@ -190,6 +107,4 @@ protected void finalize() throws Throwable { // Private c++ native methods private native HybridData initHybrid(float pixelDensity); - private native void notifyDrawLoop(); - private native void notifyTaskReady(); } \ No newline at end of file diff --git a/packages/skia/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java b/packages/skia/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java index 5db84cf185..ecaa197a6f 100644 --- a/packages/skia/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java +++ b/packages/skia/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java @@ -12,7 +12,7 @@ import java.lang.ref.WeakReference; @ReactModule(name="RNSkiaModule") -public class RNSkiaModule extends NativeSkiaModuleSpec implements LifecycleEventListener { +public class RNSkiaModule extends NativeSkiaModuleSpec { public static final String NAME = "RNSkiaModule"; private final WeakReference weakReactContext; @@ -21,17 +21,12 @@ public class RNSkiaModule extends NativeSkiaModuleSpec implements LifecycleEvent public RNSkiaModule(ReactApplicationContext reactContext) { super(reactContext); this.weakReactContext = new WeakReference<>(reactContext); - reactContext.addLifecycleEventListener(this); } @Override public void invalidate() { super.invalidate(); - if (getReactApplicationContext() != null) { - getReactApplicationContext().removeLifecycleEventListener(this); - } - if (this.skiaManager != null) { this.skiaManager.invalidate(); this.skiaManager.destroy(); @@ -69,19 +64,4 @@ public boolean install() { return false; } } - - @Override - public void onHostResume() { - if(skiaManager != null) skiaManager.onHostResume(); - } - - @Override - public void onHostPause() { - if(skiaManager != null) skiaManager.onHostPause(); - } - - @Override - public void onHostDestroy() { - - } } diff --git a/packages/skia/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java b/packages/skia/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java index ac052e6ba1..bf31a7936b 100644 --- a/packages/skia/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java +++ b/packages/skia/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java @@ -43,10 +43,6 @@ public PlatformContext getPlatformContext() { return mPlatformContext; } - public void onHostResume() { mPlatformContext.onResume(); } - - public void onHostPause() { mPlatformContext.onPause(); } - // private C++ functions private native HybridData initHybrid(long jsContext, RuntimeExecutor runtimeExecutor, PlatformContext platformContext); diff --git a/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java b/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java index 8c6e33171d..929f675b29 100644 --- a/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +++ b/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java @@ -21,11 +21,8 @@ public SkiaDomViewManagerDelegate(U viewManager) { @Override public void setProperty(T view, String propName, @Nullable Object value) { switch (propName) { - case "mode": - mViewManager.setMode(view, value == null ? null : (String) value); - break; case "debug": - mViewManager.setDebug(view, value == null ? false : (boolean) value); + mViewManager.setDebug(view, value != null && (boolean) value); break; default: super.setProperty(view, propName, value); diff --git a/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java b/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java index 6c8b24539b..b3ceeab3ac 100644 --- a/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +++ b/packages/skia/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java @@ -13,6 +13,5 @@ import androidx.annotation.Nullable; public interface SkiaDomViewManagerInterface { - void setMode(T view, @Nullable String value); void setDebug(T view, boolean value); } diff --git a/packages/skia/cpp/rnskia/RNSkDispatchQueue.cpp b/packages/skia/cpp/rnskia/RNSkDispatchQueue.cpp deleted file mode 100644 index d9e1727ee6..0000000000 --- a/packages/skia/cpp/rnskia/RNSkDispatchQueue.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "RNSkDispatchQueue.h" - -#include -#include -#include - -namespace RNSkia { - -RNSkDispatchQueue::~RNSkDispatchQueue() { - // Signal to dispatch threads that it's time to wrap up - std::unique_lock lock(lock_); - quit_ = true; - lock.unlock(); - cv_.notify_all(); - - // Wait for threads to finish before we exit - for (size_t i = 0; i < threads_.size(); i++) { - if (threads_[i].joinable()) { - threads_[i].join(); - } - } -} - -RNSkDispatchQueue::RNSkDispatchQueue(std::string name, size_t thread_cnt) - : name_{std::move(name)}, threads_(thread_cnt) { - for (size_t i = 0; i < threads_.size(); i++) { - threads_[i] = - std::thread(&RNSkDispatchQueue::dispatch_thread_handler, this); - } -} - -void RNSkDispatchQueue::dispatch(const fp_t &op) { - std::unique_lock lock(lock_); - q_.push(op); - - // Manual unlocking is done before notifying, to avoid waking up - // the waiting thread only to block again (see notify_one for details) - lock.unlock(); - cv_.notify_one(); -} - -void RNSkDispatchQueue::dispatch(fp_t &&op) { - std::unique_lock lock(lock_); - q_.push(std::move(op)); - - // Manual unlocking is done before notifying, to avoid waking up - // the waiting thread only to block again (see notify_one for details) - lock.unlock(); - cv_.notify_one(); -} - -void RNSkDispatchQueue::dispatch_thread_handler(void) { - std::unique_lock lock(lock_); - - do { - // Wait until we have data or a quit signal - cv_.wait(lock, [this] { return (q_.size() || quit_); }); - - // after wait, we own the lock - if (!quit_ && q_.size()) { - auto op = std::move(q_.front()); - q_.pop(); - - // unlock now that we're done messing with the queue - lock.unlock(); - - op(); - - lock.lock(); - } - } while (!quit_); -} -} // namespace RNSkia diff --git a/packages/skia/cpp/rnskia/RNSkDispatchQueue.h b/packages/skia/cpp/rnskia/RNSkDispatchQueue.h deleted file mode 100644 index a53ce2822b..0000000000 --- a/packages/skia/cpp/rnskia/RNSkDispatchQueue.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// https://github.com/embeddedartistry/embedded-resources/blob/master/examples/cpp/dispatch.cpp -namespace RNSkia { - -class RNSkDispatchQueue { - typedef std::function fp_t; - -public: - explicit RNSkDispatchQueue(std::string name, size_t thread_cnt = 1); - - ~RNSkDispatchQueue(); - - // dispatch and copy - void dispatch(const fp_t &op); - - // dispatch and move - void dispatch(fp_t &&op); - - // Deleted operations - RNSkDispatchQueue(const RNSkDispatchQueue &rhs) = delete; - - RNSkDispatchQueue &operator=(const RNSkDispatchQueue &rhs) = delete; - - RNSkDispatchQueue(RNSkDispatchQueue &&rhs) = delete; - - RNSkDispatchQueue &operator=(RNSkDispatchQueue &&rhs) = delete; - -private: - std::string name_; - std::mutex lock_; - std::vector threads_; - std::queue q_; - std::condition_variable cv_; - bool quit_ = false; - - void dispatch_thread_handler(void); -}; -} // namespace RNSkia diff --git a/packages/skia/cpp/rnskia/RNSkManager.cpp b/packages/skia/cpp/rnskia/RNSkManager.cpp index 87ea6c8c69..cb56782e4d 100644 --- a/packages/skia/cpp/rnskia/RNSkManager.cpp +++ b/packages/skia/cpp/rnskia/RNSkManager.cpp @@ -47,13 +47,12 @@ void RNSkManager::invalidate() { // Invalidate members _viewApi->unregisterAll(); - _platformContext->invalidate(); } void RNSkManager::registerSkiaView(size_t nativeId, std::shared_ptr view) { if (!_isInvalidated && _viewApi != nullptr) - _viewApi->registerSkiaView(nativeId, view); + _viewApi->registerSkiaView(nativeId, std::move(view)); } void RNSkManager::unregisterSkiaView(size_t nativeId) { @@ -63,7 +62,7 @@ void RNSkManager::unregisterSkiaView(size_t nativeId) { void RNSkManager::setSkiaView(size_t nativeId, std::shared_ptr view) { if (!_isInvalidated && _viewApi != nullptr) - _viewApi->setSkiaView(nativeId, view); + _viewApi->setSkiaView(nativeId, std::move(view)); } void RNSkManager::installBindings() { diff --git a/packages/skia/cpp/rnskia/RNSkPlatformContext.h b/packages/skia/cpp/rnskia/RNSkPlatformContext.h index 1c7b88a748..e64d6deef0 100644 --- a/packages/skia/cpp/rnskia/RNSkPlatformContext.h +++ b/packages/skia/cpp/rnskia/RNSkPlatformContext.h @@ -9,7 +9,6 @@ #include #include -#include "RNSkDispatchQueue.h" #include "RNSkVideo.h" #include "WindowContext.h" @@ -42,57 +41,19 @@ class RNSkPlatformContext { std::shared_ptr callInvoker, float pixelDensity) : _pixelDensity(pixelDensity), _jsRuntime(runtime), - _callInvoker(callInvoker), - _dispatchQueue( - std::make_unique("skia-render-thread")) { - _jsThreadId = std::this_thread::get_id(); + _callInvoker(callInvoker) { } - /** - * Destructor - */ - virtual ~RNSkPlatformContext() { invalidate(); } - - void invalidate() { - if (!_isValid) { - return; - } - // Stop the refresh loop - stopDrawLoop(); - // Notify draw loop listeners once with the invalidated parameter - // set to true signalling that we are done and can clean up. - notifyDrawLoop(true); - _isValid = false; - } - - /* - Returns true if the current execution context is the javascript thread. - */ - bool isOnJavascriptThread() { - return _jsThreadId == std::this_thread::get_id(); - } + virtual ~RNSkPlatformContext() = default; /** * Schedules the function to be run on the javascript thread async * @param func Function to run */ void runOnJavascriptThread(std::function func) { - if (!_isValid) { - return; - } _callInvoker->invokeAsync(std::move(func)); } - /** - Runs the function on the render thread - */ - void runOnRenderThread(std::function func) { - if (!_isValid) { - return; - } - _dispatchQueue->dispatch(std::move(func)); - } - /** * Runs the passed function on the main thread * @param func Function to run. @@ -192,82 +153,9 @@ class RNSkPlatformContext { */ float getPixelDensity() { return _pixelDensity; } - /** - * Starts (if not started) a loop that will call back on display sync - * @param callback Callback to call on sync - * @returns Identifier of the draw loop entry - */ - size_t beginDrawLoop(size_t nativeId, std::function callback) { - if (!_isValid) { - return 0; - } - auto shouldStart = false; - { - std::lock_guard lock(_drawCallbacksLock); - _drawCallbacks.emplace(nativeId, std::move(callback)); - shouldStart = _drawCallbacks.size() == 1; - } - if (shouldStart) { - // Start - startDrawLoop(); - } - return nativeId; - } - - /** - * Ends (if running) the drawing loop that was started with beginDrawLoop. - * This method must be called symmetrically with the beginDrawLoop method. - * @param nativeId Identifier of view to end - */ - void endDrawLoop(size_t nativeId) { - if (!_isValid) { - return; - } - auto shouldStop = false; - { - std::lock_guard lock(_drawCallbacksLock); - if (_drawCallbacks.count(nativeId) > 0) { - _drawCallbacks.erase(nativeId); - } - shouldStop = _drawCallbacks.size() == 0; - } - if (shouldStop) { - stopDrawLoop(); - } - } - - /** - * Notifies all drawing callbacks - * @param invalidated True if the context was invalidated, otherwise false. - * This can be used to receive a notification that we have stopped the main - * drawloop - */ - void notifyDrawLoop(bool invalidated) { - if (!_isValid) { - return; - } - std::lock_guard lock(_drawCallbacksLock); - for (auto it = _drawCallbacks.begin(); it != _drawCallbacks.end(); it++) { - it->second(invalidated); - } - } - - // default implementation does nothing, so it can be called from virtual - // destructor. - virtual void startDrawLoop() {} - virtual void stopDrawLoop() {} - private: float _pixelDensity; - - std::thread::id _jsThreadId; - jsi::Runtime *_jsRuntime; std::shared_ptr _callInvoker; - std::unique_ptr _dispatchQueue; - - std::unordered_map> _drawCallbacks; - std::mutex _drawCallbacksLock; - std::atomic _isValid = {true}; }; } // namespace RNSkia diff --git a/packages/skia/cpp/rnskia/RNSkView.h b/packages/skia/cpp/rnskia/RNSkView.h index 447e1a7baf..85c30ec4f2 100644 --- a/packages/skia/cpp/rnskia/RNSkView.h +++ b/packages/skia/cpp/rnskia/RNSkView.h @@ -145,8 +145,6 @@ class RNSkOffscreenCanvasProvider : public RNSkCanvasProvider { std::shared_ptr _context; }; -enum RNSkDrawingMode { Default, Continuous }; - class RNSkView : public std::enable_shared_from_this { public: /** @@ -161,7 +159,7 @@ class RNSkView : public std::enable_shared_from_this { /** Destructor */ - virtual ~RNSkView() { endDrawingLoop(); } + virtual ~RNSkView() {} /** Sets custom properties. Custom properties are properties that are set @@ -172,43 +170,33 @@ class RNSkView : public std::enable_shared_from_this { // Nothing here... } - /** - * Repaints the Skia view using the underlying context and the drawcallback. - * This method schedules a draw request that will be run on the correct - * thread and js runtime. - */ - void requestRedraw() { _redrawRequestCounter++; } + void requestRedraw() { + if (!_redrawRequested) { + _redrawRequested = true; + _platformContext->runOnMainThread([this]() { + if (_renderer) { + _renderer->renderImmediate(_canvasProvider); + _redrawRequested = false; + } + }); + } + } - /** - Renders immediate. Be carefull to not call this method from another thread - than the UI thread - */ - void renderImmediate() { + void redraw() { _renderer->renderImmediate(_canvasProvider); - _redrawRequestCounter = 0; + _redrawRequested = false; } /** Sets the native id of the view */ - virtual void setNativeId(size_t nativeId) { - _nativeId = nativeId; - beginDrawingLoop(); - } + virtual void setNativeId(size_t nativeId) { _nativeId = nativeId; } /** Returns the native id */ size_t getNativeId() { return _nativeId; } - /** - Sets the drawing mode for the view - */ - void setDrawingMode(RNSkDrawingMode mode) { - _drawingMode = mode; - requestRedraw(); - } - /** * Set to true to show the debug overlays on render */ @@ -240,61 +228,14 @@ class RNSkView : public std::enable_shared_from_this { return _canvasProvider; } - /** - Ends an ongoing beginDrawCallback loop for this view. This method is made - protected if the drawing loop should be stopped before reaching the - destructor (like we do for Android views) - */ - void endDrawingLoop() { - if (_drawingLoopId != 0) { - _drawingLoopId = 0; - _platformContext->endDrawLoop(_nativeId); - } - } - private: - /** - Starts beginDrawCallback loop if the drawing mode is continuous - */ - void beginDrawingLoop() { - if (_drawingLoopId != 0 || _nativeId == 0) { - return; - } - // Set to zero to avoid calling beginDrawLoop before we return - _drawingLoopId = _platformContext->beginDrawLoop( - _nativeId, [weakSelf = weak_from_this()](bool invalidated) { - auto self = weakSelf.lock(); - if (self) { - self->drawLoopCallback(invalidated); - } - }); - } - - /** - Draw loop callback - */ - void drawLoopCallback(bool invalidated) { - if (_redrawRequestCounter > 0 || - _drawingMode == RNSkDrawingMode::Continuous) { - _redrawRequestCounter = 0; - - if (!_renderer->tryRender(_canvasProvider)) { - // The renderer could not render cause it was busy, just schedule - // redrawing on the next frame. - requestRedraw(); - } - } - } - std::shared_ptr _platformContext; std::shared_ptr _canvasProvider; std::shared_ptr _renderer; - RNSkDrawingMode _drawingMode = RNSkDrawingMode::Default; size_t _nativeId; - size_t _drawingLoopId = 0; - std::atomic _redrawRequestCounter = {1}; + std::atomic _redrawRequested = {false}; }; } // namespace RNSkia diff --git a/packages/skia/ios/RNSkia-iOS/DisplayLink.h b/packages/skia/ios/RNSkia-iOS/DisplayLink.h deleted file mode 100644 index 42f414502b..0000000000 --- a/packages/skia/ios/RNSkia-iOS/DisplayLink.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#import -#import - -typedef void (^block_t)(double); -@interface DisplayLink : NSObject { - CADisplayLink *_displayLink; -} - -@property(nonatomic, copy) block_t updateBlock; - -- (void)start:(block_t)block; - -- (void)stop; - -@end diff --git a/packages/skia/ios/RNSkia-iOS/DisplayLink.mm b/packages/skia/ios/RNSkia-iOS/DisplayLink.mm deleted file mode 100644 index b57686941b..0000000000 --- a/packages/skia/ios/RNSkia-iOS/DisplayLink.mm +++ /dev/null @@ -1,41 +0,0 @@ -#import "DisplayLink.h" - -@implementation DisplayLink - -- (void)start:(block_t)block { - self.updateBlock = block; - // check whether the loop is already running - if (_displayLink == nil) { - // specify update method - _displayLink = [CADisplayLink displayLinkWithTarget:self - selector:@selector(update:)]; - - if (@available(iOS 15.0, *)) { - CAFrameRateRange rate = CAFrameRateRangeMake(60, 120, 120); - _displayLink.preferredFrameRateRange = rate; - } else { - _displayLink.preferredFramesPerSecond = 60; - } - - // add the display link to the main run loop - [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] - forMode:NSRunLoopCommonModes]; - } -} - -- (void)stop { - // check whether the loop is already stopped - if (_displayLink != nil) { - // if the display link is present, it gets invalidated (loop stops) - - [_displayLink invalidate]; - _displayLink = nil; - } -} - -- (void)update:(CADisplayLink *)sender { - double time = [sender timestamp]; - _updateBlock(time); -} - -@end diff --git a/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.h b/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.h index 52f9dd1a3e..0ee6bda0b6 100644 --- a/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +++ b/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.h @@ -7,7 +7,6 @@ #include #include -#include "DisplayLink.h" #include "RNSkPlatformContext.h" #include "ViewScreenshotService.h" @@ -49,12 +48,8 @@ class RNSkiOSPlatformContext : public RNSkPlatformContext { ~RNSkiOSPlatformContext() { CFNotificationCenterRemoveEveryObserver( CFNotificationCenterGetLocalCenter(), this); - stopDrawLoop(); } - void startDrawLoop() override; - void stopDrawLoop() override; - void runOnMainThread(std::function) override; sk_sp takeScreenshotFromViewTag(size_t tag) override; @@ -81,13 +76,9 @@ class RNSkiOSPlatformContext : public RNSkPlatformContext { #endif sk_sp createFontMgr() override; - void willInvalidateModules() { - // We need to do some house-cleaning here! - invalidate(); - } + void willInvalidateModules() {} private: - DisplayLink *_displayLink; ViewScreenshotService *_screenshotService; }; diff --git a/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm b/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm index 46add0e16a..5e39eb670a 100644 --- a/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +++ b/packages/skia/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm @@ -214,20 +214,4 @@ screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]]; } -void RNSkiOSPlatformContext::startDrawLoop() { - if (_displayLink == nullptr) { - _displayLink = [[DisplayLink alloc] init]; - [_displayLink start:^(double time) { - notifyDrawLoop(false); - }]; - } -} - -void RNSkiOSPlatformContext::stopDrawLoop() { - if (_displayLink != nullptr) { - [_displayLink stop]; - _displayLink = nullptr; - } -} - } // namespace RNSkia diff --git a/packages/skia/ios/RNSkia-iOS/SkiaDomView.mm b/packages/skia/ios/RNSkia-iOS/SkiaDomView.mm index a8b95aa338..1f1bdb56d3 100644 --- a/packages/skia/ios/RNSkia-iOS/SkiaDomView.mm +++ b/packages/skia/ios/RNSkia-iOS/SkiaDomView.mm @@ -51,7 +51,6 @@ - (void)updateProps:(const Props::Shared &)props int nativeId = [[RCTConvert NSString:RCTNSStringFromString(newProps.nativeId)] intValue]; [self setNativeId:nativeId]; - [self setDrawingMode:newProps.mode]; [self setDebugMode:newProps.debug]; } diff --git a/packages/skia/ios/RNSkia-iOS/SkiaDomViewManager.mm b/packages/skia/ios/RNSkia-iOS/SkiaDomViewManager.mm index 334372cfa1..0710c0a38a 100644 --- a/packages/skia/ios/RNSkia-iOS/SkiaDomViewManager.mm +++ b/packages/skia/ios/RNSkia-iOS/SkiaDomViewManager.mm @@ -26,12 +26,6 @@ - (SkiaManager *)skiaManager { [(SkiaUIView *)view setNativeId:nativeId]; } -RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) { - std::string mode = - json != NULL ? [[RCTConvert NSString:json] UTF8String] : "default"; - [(SkiaUIView *)view setDrawingMode:mode]; -} - RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) { bool debug = json != NULL ? [RCTConvert BOOL:json] : false; [(SkiaUIView *)view setDebugMode:debug]; diff --git a/packages/skia/ios/RNSkia-iOS/SkiaPictureView.mm b/packages/skia/ios/RNSkia-iOS/SkiaPictureView.mm index 04a69f06f9..022f409d91 100644 --- a/packages/skia/ios/RNSkia-iOS/SkiaPictureView.mm +++ b/packages/skia/ios/RNSkia-iOS/SkiaPictureView.mm @@ -53,7 +53,6 @@ - (void)updateProps:(const Props::Shared &)props int nativeId = [[RCTConvert NSString:RCTNSStringFromString(newProps.nativeId)] intValue]; [self setNativeId:nativeId]; - [self setDrawingMode:newProps.mode]; [self setDebugMode:newProps.debug]; } diff --git a/packages/skia/ios/RNSkia-iOS/SkiaPictureViewManager.mm b/packages/skia/ios/RNSkia-iOS/SkiaPictureViewManager.mm index fcf786f476..ce2eef8483 100644 --- a/packages/skia/ios/RNSkia-iOS/SkiaPictureViewManager.mm +++ b/packages/skia/ios/RNSkia-iOS/SkiaPictureViewManager.mm @@ -26,12 +26,6 @@ - (SkiaManager *)skiaManager { [(SkiaUIView *)view setNativeId:nativeId]; } -RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) { - std::string mode = - json != NULL ? [[RCTConvert NSString:json] UTF8String] : "default"; - [(SkiaUIView *)view setDrawingMode:mode]; -} - RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) { bool debug = json != NULL ? [RCTConvert BOOL:json] : false; [(SkiaUIView *)view setDebugMode:debug]; diff --git a/packages/skia/ios/RNSkia-iOS/SkiaUIView.h b/packages/skia/ios/RNSkia-iOS/SkiaUIView.h index 7e8e1d5a2e..fb2bb6d278 100644 --- a/packages/skia/ios/RNSkia-iOS/SkiaUIView.h +++ b/packages/skia/ios/RNSkia-iOS/SkiaUIView.h @@ -31,7 +31,6 @@ - (std::shared_ptr)impl; - (SkiaManager *)skiaManager; -- (void)setDrawingMode:(std::string)mode; - (void)setDebugMode:(bool)debugMode; - (void)setNativeId:(size_t)nativeId; diff --git a/packages/skia/ios/RNSkia-iOS/SkiaUIView.mm b/packages/skia/ios/RNSkia-iOS/SkiaUIView.mm index 44efd69506..7a2209aad5 100644 --- a/packages/skia/ios/RNSkia-iOS/SkiaUIView.mm +++ b/packages/skia/ios/RNSkia-iOS/SkiaUIView.mm @@ -11,7 +11,6 @@ @implementation SkiaUIView { std::shared_ptr _impl; RNSkia::RNSkManager *_manager; - RNSkia::RNSkDrawingMode _drawingMode; std::function( std::shared_ptr)> _factory; @@ -45,7 +44,6 @@ - (void)initCommon:(RNSkia::RNSkManager *)manager _manager = manager; _nativeId = 0; _debugMode = false; - _drawingMode = RNSkia::RNSkDrawingMode::Default; _factory = factory; } @@ -86,7 +84,6 @@ - (void)willMoveToSuperview:(UIView *)newWindow { if (_nativeId != 0) { _manager->setSkiaView(_nativeId, _impl->getDrawView()); } - _impl->getDrawView()->setDrawingMode(_drawingMode); _impl->getDrawView()->setShowDebugOverlays(_debugMode); } } @@ -131,7 +128,7 @@ - (void)drawRect:(CGRect)rect { // We override drawRect to ensure we to direct rendering when the // underlying OS view needs to render: if (_impl != nullptr) { - _impl->getDrawView()->renderImmediate(); + _impl->getDrawView()->redraw(); } } @@ -146,16 +143,6 @@ - (void)layoutSubviews { #pragma mark Properties -- (void)setDrawingMode:(std::string)mode { - _drawingMode = mode.compare("continuous") == 0 - ? RNSkia::RNSkDrawingMode::Continuous - : RNSkia::RNSkDrawingMode::Default; - - if (_impl != nullptr) { - _impl->getDrawView()->setDrawingMode(_drawingMode); - } -} - - (void)setDebugMode:(bool)debugMode { _debugMode = debugMode; if (_impl != nullptr) { diff --git a/packages/skia/src/renderer/Canvas.tsx b/packages/skia/src/renderer/Canvas.tsx index 90f1184886..b7ee9c00ec 100644 --- a/packages/skia/src/renderer/Canvas.tsx +++ b/packages/skia/src/renderer/Canvas.tsx @@ -27,6 +27,7 @@ export const useCanvasRef = () => useRef(null); export interface CanvasProps extends SkiaBaseViewProps { ref?: RefObject; children: ReactNode; + mode?: "default" | "continuous"; } const useOnSizeEvent = ( @@ -54,7 +55,7 @@ export const Canvas = forwardRef( children, style, debug, - mode, + mode = "default", onSize: _onSize, onLayout: _onLayout, ...props @@ -95,8 +96,8 @@ export const Canvas = forwardRef( style={style} root={root.dom} onLayout={onLayout} - mode={mode} debug={debug} + mode={mode} {...props} /> ); @@ -104,12 +105,12 @@ export const Canvas = forwardRef( return ( diff --git a/packages/skia/src/specs/SkiaPictureViewNativeComponent.ts b/packages/skia/src/specs/SkiaPictureViewNativeComponent.ts index c28e43c8d7..79cfba1dc4 100644 --- a/packages/skia/src/specs/SkiaPictureViewNativeComponent.ts +++ b/packages/skia/src/specs/SkiaPictureViewNativeComponent.ts @@ -2,7 +2,6 @@ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNati import type { ViewProps } from "react-native"; export interface NativeProps extends ViewProps { - mode: string; debug?: boolean; } diff --git a/packages/skia/src/views/SkiaBaseWebView.tsx b/packages/skia/src/views/SkiaBaseWebView.tsx index d0f812321c..161b5d4036 100644 --- a/packages/skia/src/views/SkiaBaseWebView.tsx +++ b/packages/skia/src/views/SkiaBaseWebView.tsx @@ -6,7 +6,7 @@ import type { SkRect, SkCanvas } from "../skia/types"; import { JsiSkSurface } from "../skia/web/JsiSkSurface"; import { Platform } from "../Platform"; -import type { DrawMode, SkiaBaseViewProps } from "./types"; +import type { SkiaBaseViewProps } from "./types"; const pd = Platform.PixelRatio; @@ -15,14 +15,12 @@ export abstract class SkiaBaseWebView< > extends React.Component { constructor(props: TProps) { super(props); - this._mode = props.mode ?? "default"; } private _surface: JsiSkSurface | null = null; private _unsubscriptions: Array<() => void> = []; private _canvas: SkCanvas | null = null; private _canvasRef = React.createRef(); - private _mode: DrawMode; private _redrawRequests = 0; private requestId = 0; @@ -106,7 +104,7 @@ export abstract class SkiaBaseWebView< * Sends a redraw request to the native SkiaView. */ private tick() { - if (this._mode === "continuous" || this._redrawRequests > 0) { + if (this._redrawRequests > 0) { this._redrawRequests = 0; if (this._canvas) { const canvas = this._canvas!; @@ -125,24 +123,10 @@ export abstract class SkiaBaseWebView< this._redrawRequests++; } - /** - * Updates the drawing mode for the skia view. This is the same - * as declaratively setting the mode property on the SkiaView. - * There are two drawing modes, "continuous" and "default", - * where the continuous mode will continuously redraw the view and - * the default mode will only redraw when any of the regular react - * properties are changed like size and margins. - * @param mode Drawing mode to use. - */ - public setDrawMode(mode: DrawMode) { - this._mode = mode; - this.tick(); - } - private onLayout = this.onLayoutEvent.bind(this); render() { - const { mode, debug = false, ...viewProps } = this.props; + const { debug = false, ...viewProps } = this.props; return ( diff --git a/packages/skia/src/views/SkiaDomView.tsx b/packages/skia/src/views/SkiaDomView.tsx index 9997713db6..593ac66f4e 100644 --- a/packages/skia/src/views/SkiaDomView.tsx +++ b/packages/skia/src/views/SkiaDomView.tsx @@ -6,15 +6,19 @@ import { Platform } from "../Platform"; import SkiaDomViewNativeComponent from "../specs/SkiaDomViewNativeComponent"; import { SkiaViewApi } from "./api"; -import type { SkiaDomViewProps } from "./types"; +import type { SkiaDomViewNativeProps } from "./types"; import { SkiaViewNativeId } from "./SkiaViewNativeId"; -const NativeSkiaDomView: HostComponent = +const NativeSkiaDomView: HostComponent = Platform.OS !== "web" ? SkiaDomViewNativeComponent : // eslint-disable-next-line @typescript-eslint/no-explicit-any (null as any); +interface SkiaDomViewProps extends SkiaDomViewNativeProps { + mode?: "default" | "continuous"; +} + export class SkiaDomView extends React.Component { constructor(props: SkiaDomViewProps) { super(props); @@ -28,9 +32,11 @@ export class SkiaDomView extends React.Component { assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize); } + this.tick(); } private _nativeId: number; + private requestId = 0; public get nativeId() { return this._nativeId; @@ -46,6 +52,20 @@ export class SkiaDomView extends React.Component { assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize); } + this.tick(); + } + + componentWillUnmount(): void { + if (this.requestId) { + cancelAnimationFrame(this.requestId); + } + } + + private tick() { + this.redraw(); + if (this.props.mode === "continuous") { + this.requestId = requestAnimationFrame(this.tick.bind(this)); + } } /** @@ -77,12 +97,11 @@ export class SkiaDomView extends React.Component { } render() { - const { mode, debug = false, ...viewProps } = this.props; + const { debug = false, ...viewProps } = this.props; return ( diff --git a/packages/skia/src/views/SkiaDomView.web.tsx b/packages/skia/src/views/SkiaDomView.web.tsx index 73254587c7..0ba959b024 100644 --- a/packages/skia/src/views/SkiaDomView.web.tsx +++ b/packages/skia/src/views/SkiaDomView.web.tsx @@ -3,10 +3,10 @@ import type { SkCanvas } from "../skia/types"; import { JsiDrawingContext } from "../dom/types/DrawingContext"; import { SkiaBaseWebView } from "./SkiaBaseWebView"; -import type { SkiaDomViewProps } from "./types"; +import type { SkiaDomViewNativeProps } from "./types"; -export class SkiaDomView extends SkiaBaseWebView { - constructor(props: SkiaDomViewProps) { +export class SkiaDomView extends SkiaBaseWebView { + constructor(props: SkiaDomViewNativeProps) { super(props); } diff --git a/packages/skia/src/views/SkiaJSDomView.tsx b/packages/skia/src/views/SkiaJSDomView.tsx index 65b41043f8..a0139bf9ab 100644 --- a/packages/skia/src/views/SkiaJSDomView.tsx +++ b/packages/skia/src/views/SkiaJSDomView.tsx @@ -7,19 +7,29 @@ import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeCompon import { JsiDrawingContext } from "../dom/types"; import { SkiaViewApi } from "./api"; -import type { SkiaPictureViewProps, SkiaDomViewProps } from "./types"; +import type { + SkiaPictureViewNativeProps, + SkiaDomViewNativeProps, +} from "./types"; import { SkiaViewNativeId } from "./SkiaViewNativeId"; -const NativeSkiaPictureView: HostComponent = +const NativeSkiaPictureView: HostComponent = Platform.OS !== "web" ? SkiaPictureViewNativeComponent : // eslint-disable-next-line @typescript-eslint/no-explicit-any (null as any); -export class SkiaJSDomView extends React.Component< - SkiaDomViewProps & { Skia: Skia } -> { - constructor(props: SkiaDomViewProps & { Skia: Skia }) { +interface SkiaDomViewProps extends SkiaDomViewNativeProps { + mode?: "default" | "continuous"; +} + +type SkiaJSDomViewProps = SkiaDomViewProps & { + Skia: Skia; + mode?: "default" | "continuous"; +}; + +export class SkiaJSDomView extends React.Component { + constructor(props: SkiaJSDomViewProps) { super(props); this._nativeId = SkiaViewNativeId.current++; const { root, onSize } = props; @@ -31,9 +41,18 @@ export class SkiaJSDomView extends React.Component< assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize); } + this.tick(); } private _nativeId: number; + private requestId = 0; + + private tick() { + this.redraw(); + if (this.props.mode === "continuous") { + this.requestId = requestAnimationFrame(this.tick.bind(this)); + } + } public get nativeId() { return this._nativeId; @@ -49,6 +68,7 @@ export class SkiaJSDomView extends React.Component< assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize); } + this.tick(); } /** @@ -67,7 +87,6 @@ export class SkiaJSDomView extends React.Component< public redraw() { assertSkiaViewApi(); this.draw(); - //SkiaViewApi.requestRedraw(this._nativeId); } private draw() { @@ -89,15 +108,17 @@ export class SkiaJSDomView extends React.Component< componentWillUnmount(): void { assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "picture", null); + if (this.requestId) { + cancelAnimationFrame(this.requestId); + } } render() { - const { mode, debug = false, ...viewProps } = this.props; + const { debug = false, ...viewProps } = this.props; return ( diff --git a/packages/skia/src/views/SkiaPictureView.tsx b/packages/skia/src/views/SkiaPictureView.tsx index bb91bd2049..bc9ea2314c 100644 --- a/packages/skia/src/views/SkiaPictureView.tsx +++ b/packages/skia/src/views/SkiaPictureView.tsx @@ -4,12 +4,18 @@ import type { SkRect } from "../skia/types"; import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent"; import { SkiaViewApi } from "./api"; -import type { SkiaPictureViewProps } from "./types"; +import type { SkiaPictureViewNativeProps } from "./types"; import { SkiaViewNativeId } from "./SkiaViewNativeId"; const NativeSkiaPictureView = SkiaPictureViewNativeComponent; +interface SkiaPictureViewProps extends SkiaPictureViewNativeProps { + mode?: "default" | "continuous"; +} + export class SkiaPictureView extends React.Component { + private requestId = 0; + constructor(props: SkiaPictureViewProps) { super(props); this._nativeId = SkiaViewNativeId.current++; @@ -22,6 +28,7 @@ export class SkiaPictureView extends React.Component { assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize); } + this.tick(); } private _nativeId: number; @@ -40,6 +47,20 @@ export class SkiaPictureView extends React.Component { assertSkiaViewApi(); SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize); } + this.tick(); + } + + componentWillUnmount() { + if (this.requestId) { + cancelAnimationFrame(this.requestId); + } + } + + private tick() { + this.redraw(); + if (this.props.mode === "continuous") { + this.requestId = requestAnimationFrame(this.tick.bind(this)); + } } /** @@ -66,7 +87,6 @@ export class SkiaPictureView extends React.Component { diff --git a/packages/skia/src/views/SkiaPictureView.web.tsx b/packages/skia/src/views/SkiaPictureView.web.tsx index 72902cd875..5ed2fd60d4 100644 --- a/packages/skia/src/views/SkiaPictureView.web.tsx +++ b/packages/skia/src/views/SkiaPictureView.web.tsx @@ -1,10 +1,10 @@ import type { SkCanvas } from "../skia/types"; -import type { SkiaPictureViewProps } from "./types"; +import type { SkiaPictureViewNativeProps } from "./types"; import { SkiaBaseWebView } from "./SkiaBaseWebView"; -export class SkiaPictureView extends SkiaBaseWebView { - constructor(props: SkiaPictureViewProps) { +export class SkiaPictureView extends SkiaBaseWebView { + constructor(props: SkiaPictureViewNativeProps) { super(props); } diff --git a/packages/skia/src/views/types.ts b/packages/skia/src/views/types.ts index 603f8c8a96..0d53e1f8bb 100644 --- a/packages/skia/src/views/types.ts +++ b/packages/skia/src/views/types.ts @@ -4,10 +4,7 @@ import type { GroupProps, RenderNode } from "../dom/types"; import type { SkImage, SkPicture, SkRect, SkSize } from "../skia/types"; import type { SharedValueType } from "../renderer/processors/Animations/Animations"; -export type DrawMode = "continuous" | "default"; - export type NativeSkiaViewProps = ViewProps & { - mode?: DrawMode; debug?: boolean; }; @@ -25,14 +22,6 @@ export interface ISkiaViewApi { } export interface SkiaBaseViewProps extends ViewProps { - /** - * Sets the drawing mode for the skia view. There are two drawing - * modes, "continuous" and "default", where the continuous mode will - * continuously redraw the view, and the default mode will only - * redraw when any of the regular react properties are changed like - * sizes and margins. - */ - mode?: DrawMode; /** * When set to true the view will display information about the * average time it takes to render. @@ -45,10 +34,10 @@ export interface SkiaBaseViewProps extends ViewProps { onSize?: SharedValueType; } -export interface SkiaPictureViewProps extends SkiaBaseViewProps { +export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps { picture?: SkPicture; } -export interface SkiaDomViewProps extends SkiaBaseViewProps { +export interface SkiaDomViewNativeProps extends SkiaBaseViewProps { root?: RenderNode; }