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 <philterdesign@gmail.com> 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
This commit is contained in:
mjtalbot
2024-05-08 15:13:24 +00:00
parent 693585e925
commit b1aed84464
7 changed files with 41 additions and 7 deletions

View File

@@ -1 +1 @@
1d0d2b6acd58a8541bf0fa01a9ac0b5bb761e65a
4342a3f049632b640b5522c1fabf7aef781423af

View File

@@ -1 +1 @@
247fba9f46f26ac73357746fa351c5557a61c4ec
682b2894c95b37438ce2e0e0d7d25de7b8ea9b24

View File

@@ -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")]
)
]
)

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
</dict>
</plist>

View File

@@ -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

View File

@@ -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 = "<group>"; };
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 = "<group>"; };
83DE4C9F2AAA072B00B88B72 /* PlatformCGImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCGImage.mm; sourceTree = "<group>"; };
@@ -290,6 +292,14 @@
name = Frameworks;
sourceTree = "<group>";
};
2E54F2382BE428750013016C /* Resources */ = {
isa = PBXGroup;
children = (
2E54F2392BE428990013016C /* PrivacyInfo.xcprivacy */,
);
path = Resources;
sourceTree = "<group>";
};
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;