From b1aed844649751cd824d6621e24e0e41a37cbfe9 Mon Sep 17 00:00:00 2001 From: mjtalbot Date: Wed, 8 May 2024 15:13:24 +0000 Subject: [PATCH] Pushing merge, resolved using upstream.\n\n message=Wasm fallback and min safari version ### This PR - fixes WASM not loading on older Apple devices/browsers - adds a fallback mechanism #### Fix for older devices The addition of `MIN_SAFARI_VERSION` is the only flag that resolved the issue on the affected devices (see discussion: https://2dimensions.slack.com/archives/CLLCU09T6/p1714494911457529) #### Fallback This PR is meant to showcase a way to introduce a fallback mechanism quickly. Can it be merged? Yes. But we need to consider the impact and alternatives (see below). _Also note that this PR makes an assumption about the best way to handle our single packages, which needs to be discussed before merging (see below)._ #### Problem with this fallback We'll increase the NPM package size by having two WASM files: `rive.wasm` and `rive_fallback.wasm`. To alleviate any concern, this can be resolved with proper documentation. The packages that load the WASM remotely do so through `unpkg` or `jsdelvr` (or overridden manually). It would not have an impact on the actual end client (to my knowledge), but maybe the perception of the "increased" NPM package size is something we want to avoid. #### Benefit of this approach Quick, with minimal change. We continue to use `unpkg` and `jsdelvr` to host. #### TODO Adaptive Loading: Implement more sophisticated loading strategies, such as loading different WASM modules based on the user's browser capabilities or preferences. This draft PR only loads the fallback if the current one failed. This does not need to be part of this PR and can be a future enhancement. ### Single vs Non-Single versions **This fallback mechanism will only work for the non-single packages where we load the WASM bundle separately**. Not the **-single versions, where WASM is bundled with the JS. In my testing during the call to `loadRuntime` the callback for `locateFile` will not be called if Emscripten is built with `-sSINGLE_FILE=1`. At the time of making the draft PR I've not come up with a solution for this. It might not be possible. TODO: This needs to be investigated more. Or we should reach out to Emscripten. #### What this means If we can't create a fallback for these, then we should make a decision around our single libraries: - Should they prefer to support older architecture and we recommend that people use the non-single packages to benefit from the fallback mechanism. - Or the alternative and we still recommend using the non-single packages to benefit from a fallback. **There are other benefits to using the non-single:** - Streaming Compilation: Newer browsers can start compiling the WASM file as soon as it starts downloading, which could lead to faster execution start times. - Better Cache Control: JavaScript and WASM can be cached separately. If you update one, users may not need to re-download the other. With the single version, I can see how people may end up using it in a way where any update to their site might then be bundling everything again. ### Alternative One _Most of the above still apply._ Instead of adding `rive_fallback.wasm` to the current packages, we create another NPM package called `rive_fallback` or something. And all this package is responsible for is to distribute the fallback WASM files, for example, `rive_canvas_fallback.wasm` and `rive_webgl_fallback.wasm`. **Benefit** We do not increase the perceived NPM package size for our published packages. And we can continue to use `unpkg` and `jsdelivr` for hosting. ### Alternative Two _Most of the above still apply._ We build our own hosting with versioning, etc. Diffs= 4342a3f04 Wasm fallback and min safari version (#7214) 4c23759b6 Add privacy manifest for Apple platforms (#7194) Co-authored-by: Philip Chung diff=\n\ndiff --cc RiveRuntime.podspec index 4f684ca,d485ee4..0000000 --- a/RiveRuntime.podspec +++ b/RiveRuntime.podspec @@@ -27,12 -27,12 +27,16 @@@ Pod::Spec.new do |spec LICENSE } spec.authors = { "Luigi Rosso" => "luigi@rive.app" } - spec.platform = :ios, '14.0' spec.ios.deployment_target = '14.0' + spec.osx.deployment_target = '13.1' spec.swift_version = '5.0' spec.source = { - :http => "https://github.com/rive-app/rive-ios/releases/download/3.0.1/RiveRuntime.xcframework.zip", + :http => "https://github.com/rive-app/rive-ios/releases/download/5.11.2/RiveRuntime.xcframework.zip", } spec.ios.vendored_frameworks = 'RiveRuntime.xcframework' ++<<<<<<< ours + spec.osx.vendored_frameworks = 'RiveRuntime.xcframework' ++======= + spec.resource_bundles = {'runtime_ios_privacy' => ['Resources/PrivacyInfo.xcprivacy']} ++>>>>>>> theirs end --- .rive_head | 2 +- .rive_renderer | 2 +- Package.swift | 5 +++++ Resources/PrivacyInfo.xcprivacy | 17 +++++++++++++++++ RiveRuntime.podspec | 8 ++++---- RiveRuntime.xcodeproj/project.pbxproj | 12 ++++++++++++ submodules/rive-cpp | 2 +- 7 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 Resources/PrivacyInfo.xcprivacy diff --git a/.rive_head b/.rive_head index 2b396c2..7af1aa1 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -1d0d2b6acd58a8541bf0fa01a9ac0b5bb761e65a +4342a3f049632b640b5522c1fabf7aef781423af diff --git a/.rive_renderer b/.rive_renderer index fac294f..335fbdc 100644 --- a/.rive_renderer +++ b/.rive_renderer @@ -1 +1 @@ -247fba9f46f26ac73357746fa351c5557a61c4ec +682b2894c95b37438ce2e0e0d7d25de7b8ea9b24 diff --git a/Package.swift b/Package.swift index 5b3cc84..f1f685b 100644 --- a/Package.swift +++ b/Package.swift @@ -14,5 +14,10 @@ let package = Package( url: "https://github.com/rive-app/rive-ios/releases/download/5.11.2/RiveRuntime.xcframework.zip", checksum: "06364ac2dc326dd3b62cbc6de266b118fafedbe216652228f053d6eb98d3bd1f" ), + .target( + name: "RiveRuntime", + path: "Resources", + resources: [.copy("PrivacyInfo.xcprivacy")] + ) ] ) diff --git a/Resources/PrivacyInfo.xcprivacy b/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..f2b2d34 --- /dev/null +++ b/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,17 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + + diff --git a/RiveRuntime.podspec b/RiveRuntime.podspec index 4f684ca..d485ee4 100644 --- a/RiveRuntime.podspec +++ b/RiveRuntime.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "RiveRuntime" - spec.version = "5.11.2" + spec.version = "3.0.1" spec.summary = "iOS SDK to render Rive animations" spec.description = "Rive is a real-time interactive design and animation tool. Use our collaborative editor to create motion graphics that respond to different states and user inputs. Then load your animations into apps, games, and websites with our lightweight open-source runtimes." spec.homepage = "https://github.com/rive-app/rive-ios" @@ -27,12 +27,12 @@ Pod::Spec.new do |spec| LICENSE } spec.authors = { "Luigi Rosso" => "luigi@rive.app" } + spec.platform = :ios, '14.0' spec.ios.deployment_target = '14.0' - spec.osx.deployment_target = '13.1' spec.swift_version = '5.0' spec.source = { - :http => "https://github.com/rive-app/rive-ios/releases/download/5.11.2/RiveRuntime.xcframework.zip", + :http => "https://github.com/rive-app/rive-ios/releases/download/3.0.1/RiveRuntime.xcframework.zip", } spec.ios.vendored_frameworks = 'RiveRuntime.xcframework' - spec.osx.vendored_frameworks = 'RiveRuntime.xcframework' + spec.resource_bundles = {'runtime_ios_privacy' => ['Resources/PrivacyInfo.xcprivacy']} end diff --git a/RiveRuntime.xcodeproj/project.pbxproj b/RiveRuntime.xcodeproj/project.pbxproj index 396c873..12472bd 100644 --- a/RiveRuntime.xcodeproj/project.pbxproj +++ b/RiveRuntime.xcodeproj/project.pbxproj @@ -68,6 +68,7 @@ 2AD589B62B574C0A00CD1D24 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B12B573C9F00CD1D24 /* CoreAudio.framework */; }; 2AD589BA2B57589400CD1D24 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B92B57589400CD1D24 /* AudioToolbox.framework */; }; 2AD589BB2B57589B00CD1D24 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AD589B92B57589400CD1D24 /* AudioToolbox.framework */; }; + 2E54F23A2BE428990013016C /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 2E54F2392BE428990013016C /* PrivacyInfo.xcprivacy */; }; 83DE4C912AA8DD7B00B88B72 /* RenderContextManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83DE4C902AA8DD7B00B88B72 /* RenderContextManager.mm */; }; 83DE4C932AA8DD9F00B88B72 /* RenderContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 83DE4C922AA8DD9F00B88B72 /* RenderContextManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; 83DE4CA02AAA072B00B88B72 /* PlatformCGImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83DE4C9F2AAA072B00B88B72 /* PlatformCGImage.mm */; }; @@ -167,6 +168,7 @@ 2AD589B12B573C9F00CD1D24 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; 2AD589B42B574C0000CD1D24 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; }; 2AD589B92B57589400CD1D24 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 2E54F2392BE428990013016C /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 83DE4C902AA8DD7B00B88B72 /* RenderContextManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RenderContextManager.mm; path = Source/Renderer/RenderContextManager.mm; sourceTree = SOURCE_ROOT; }; 83DE4C922AA8DD9F00B88B72 /* RenderContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderContextManager.h; sourceTree = ""; }; 83DE4C9F2AAA072B00B88B72 /* PlatformCGImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCGImage.mm; sourceTree = ""; }; @@ -290,6 +292,14 @@ name = Frameworks; sourceTree = ""; }; + 2E54F2382BE428750013016C /* Resources */ = { + isa = PBXGroup; + children = ( + 2E54F2392BE428990013016C /* PrivacyInfo.xcprivacy */, + ); + path = Resources; + sourceTree = ""; + }; C3468E5627EB9858008652FD /* Utils */ = { isa = PBXGroup; children = ( @@ -331,6 +341,7 @@ isa = PBXGroup; children = ( C9C73ED324FC478800EF9516 /* Source */, + 2E54F2382BE428750013016C /* Resources */, C9C73EDE24FC478900EF9516 /* Tests */, C9C73ED224FC478800EF9516 /* Products */, 2AD589AE2B5705D800CD1D24 /* Frameworks */, @@ -502,6 +513,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2E54F23A2BE428990013016C /* PrivacyInfo.xcprivacy in Resources */, E599DCF92AAFA06100D1E49A /* rating_animation.riv in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/submodules/rive-cpp b/submodules/rive-cpp index 1fadc01..448cda2 160000 --- a/submodules/rive-cpp +++ b/submodules/rive-cpp @@ -1 +1 @@ -Subproject commit 1fadc01a78f67f0599e98d91d36b1472b8b7f2c1 +Subproject commit 448cda297d1c21e3fc0a9ce63a8db1e4eca04af7