Ios out of band few bits to sort out - [x] make our mix of simulator/emulator consistent, settling on emulator - [x] passing the factory in works great for just in time asset decoding, but its not amazing when you want to decode ahead of time. - [x] couple of places left to pass this function signature through. (Question) is there a neater way to get this done, feels a bit like we are going back to parameter explosion a bit? - [x] should do a few examples, i think the complexity grows quite a bit in this one as you add caching, or callbacks - [x] should get the cached images/fonts to draw on init as well, either warming up cache, or jitting - [x] examples loading assets from the bundle (also there seem to be actual asset things too? should we use those?!) - [x] add test - [x] re-add "preview" project & rev the preview project once this has been deployed. (do this after new ios deploy) - [x] fix up race condition (see comment) https://github.com/rive-app/rive/assets/1216025/2c14330f-e8a4-481b-bc27-4807cabe3b82 (simple example, both swift ui and standard)  Diffs= fabb7f97f Ios out of band (#6232) Co-authored-by: Gordon Hayes <pggordonhayes@gmail.com> Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
diff --git a/.rive_head b/.rive_head index c640d70..1be5c7b 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -ed4474d1ab3aa1e68d47cfcb2c178f39c376257e +fabb7f97fe7b69368c9a7369febfecbc90be49cd
diff --git a/build/premake5.lua b/build/premake5.lua index bfedda2..d90d30e 100644 --- a/build/premake5.lua +++ b/build/premake5.lua
@@ -84,6 +84,7 @@ filter {'system:ios', 'options:variant=emulator'} do buildoptions { + '--target=arm64-apple-ios13.0.0-simulator', '-mios-version-min=13.0 -arch arm64 -arch x86_64 -isysroot ' .. (os.getenv('IOS_SYSROOT') or '') } targetdir '%{cfg.system}_sim/bin/%{cfg.buildcfg}'
diff --git a/dependencies/premake5_harfbuzz.lua b/dependencies/premake5_harfbuzz.lua index be3354f..b346944 100644 --- a/dependencies/premake5_harfbuzz.lua +++ b/dependencies/premake5_harfbuzz.lua
@@ -294,6 +294,7 @@ filter {'system:ios', 'options:variant=emulator'} do buildoptions { + '--target=arm64-apple-ios13.0.0-simulator', '-mios-version-min=13.0 -arch arm64 -arch x86_64 -isysroot ' .. (os.getenv('IOS_SYSROOT') or '') } targetdir '%{cfg.system}_sim/cache/bin/%{cfg.buildcfg}'
diff --git a/dependencies/premake5_sheenbidi.lua b/dependencies/premake5_sheenbidi.lua index dff476e..7cd1d99 100644 --- a/dependencies/premake5_sheenbidi.lua +++ b/dependencies/premake5_sheenbidi.lua
@@ -108,6 +108,7 @@ filter {'system:ios', 'options:variant=emulator'} do buildoptions { + '--target=arm64-apple-ios13.0.0-simulator', '-mios-version-min=13.0 -arch arm64 -arch x86_64 -isysroot ' .. (os.getenv('IOS_SYSROOT') or '') } targetdir '%{cfg.system}_sim/cache/bin/%{cfg.buildcfg}'
diff --git a/include/rive/file_asset_loader.hpp b/include/rive/file_asset_loader.hpp index 55661bb..43bb2bf 100644 --- a/include/rive/file_asset_loader.hpp +++ b/include/rive/file_asset_loader.hpp
@@ -20,7 +20,9 @@ /// @param inBandBytes is a pointer to the bytes in question /// @returns bool indicating if we are loading or have loaded the contents - virtual bool loadContents(FileAsset& asset, Span<const uint8_t> inBandBytes) = 0; + virtual bool loadContents(FileAsset& asset, + Span<const uint8_t> inBandBytes, + Factory* factory) = 0; }; } // namespace rive #endif
diff --git a/include/rive/relative_local_asset_loader.hpp b/include/rive/relative_local_asset_loader.hpp index 30d7d8a..f37271a 100644 --- a/include/rive/relative_local_asset_loader.hpp +++ b/include/rive/relative_local_asset_loader.hpp
@@ -18,10 +18,9 @@ { private: std::string m_Path; - Factory* m_Factory; public: - RelativeLocalAssetLoader(std::string filename, Factory* factory) : m_Factory(factory) + RelativeLocalAssetLoader(std::string filename) { std::size_t finalSlash = filename.rfind('/'); @@ -31,7 +30,9 @@ } } - bool loadContents(FileAsset& asset, Span<const uint8_t> inBandBytes) override + bool loadContents(FileAsset& asset, + Span<const uint8_t> inBandBytes, + rive::Factory* factory) override { std::string filename = m_Path + asset.uniqueFilename(); FILE* fp = fopen(filename.c_str(), "rb"); @@ -42,7 +43,7 @@ uint8_t* bytes = new uint8_t[length]; if (fread(bytes, 1, length, fp) == length) { - asset.decode(Span<const uint8_t>(bytes, length), m_Factory); + asset.decode(Span<const uint8_t>(bytes, length), factory); } delete[] bytes; return true;
diff --git a/skia/dependencies/make_skia.sh b/skia/dependencies/make_skia.sh index 850878c..d1f1008 100755 --- a/skia/dependencies/make_skia.sh +++ b/skia/dependencies/make_skia.sh
@@ -175,8 +175,8 @@ bin/gn gen out/iossim_arm64 --type=static_library --args=" \ target_os=\"ios\" \ target_cpu=\"arm64\" \ - extra_cflags=[\"-fno-rtti\", \"-fembed-bitcode\", \"-flto=full\", \"-DSK_DISABLE_SKPICTURE\", \"-DSK_DISABLE_TEXT\", \"-DRIVE_OPTIMIZED\", \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \"-DSK_DISABLE_AAA\", \"-DSK_DISABLE_EFFECT_DESERIALIZATION\", \"--target=arm64-apple-ios12.0.0-simulator\"] \ - extra_ldflags=[\"--target=arm64-apple-ios12.0.0-simulator\"] \ + extra_cflags=[\"-fno-rtti\", \"-fembed-bitcode\", \"-flto=full\", \"-DSK_DISABLE_SKPICTURE\", \"-DSK_DISABLE_TEXT\", \"-DRIVE_OPTIMIZED\", \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \"-DSK_DISABLE_AAA\", \"-DSK_DISABLE_EFFECT_DESERIALIZATION\", \"--target=arm64-apple-ios13.0.0-simulator\"] \ + extra_ldflags=[\"--target=arm64-apple-ios13.0.0-simulator\"] \ is_official_build=true \ skia_use_angle=false \ skia_use_dng_sdk=false \
diff --git a/skia/dependencies/make_skia_ios.sh b/skia/dependencies/make_skia_ios.sh index d4f8012..bc10d49 100755 --- a/skia/dependencies/make_skia_ios.sh +++ b/skia/dependencies/make_skia_ios.sh
@@ -6,39 +6,39 @@ source ./get_skia2.sh source ./cache_helper.sh -build_skia_ios(){ +build_skia_ios() { cd $SKIA_DIR_NAME BASE=out/ios - case $1 in - arm64) - ARCH=arm64 - FOLDER=$BASE/arm64 - ;; - arm) - ARCH=arm - FOLDER=$BASE/arm - ;; - x86) - ARCH=x86 - FOLDER=$BASE/x86 - ;; - x64) - ARCH=x64 - FOLDER=$BASE/x64 - ;; - iossim_arm64) - ARCH=arm64 - FOLDER=$BASE/iossim_arm64 - EXTRA_CFLAGS=", \"--target=arm64-apple-ios12.0.0-simulator\"" - EXTRA_LDLAGS="\"--target=arm64-apple-ios12.0.0-simulator\"" - ;; - *) - echo "Do not know build configuration for $1" - exit 1 + case $1 in + arm64) + ARCH=arm64 + FOLDER=$BASE/arm64 + ;; + arm) + ARCH=arm + FOLDER=$BASE/arm + ;; + x86) + ARCH=x86 + FOLDER=$BASE/x86 + ;; + x64) + ARCH=x64 + FOLDER=$BASE/x64 + ;; + iossim_arm64) + ARCH=arm64 + FOLDER=$BASE/iossim_arm64 + EXTRA_CFLAGS=", \"--target=arm64-apple-ios13.0.0-simulator\"" + EXTRA_LDLAGS="\"--target=arm64-apple-ios13.0.0-simulator\"" + ;; + *) + echo "Do not know build configuration for $1" + exit 1 + ;; esac - # use Rive optimized/stripped Skia for iOS static libs. bin/gn gen $FOLDER --type=static_library --args=" \ target_os=\"ios\" \ @@ -103,17 +103,17 @@ cd .. } -if is_build_cached_locally; then +if is_build_cached_locally; then echo "Build is cached, nothing to do." else - if is_build_cached_remotely; then + if is_build_cached_remotely; then pull_cache - else + else getSkia build_skia_ios $1 # hmm not the appiest with this guy OUTPUT_CACHE=$FOLDER upload_cache - fi + fi fi cd ..
diff --git a/src/importers/file_asset_importer.cpp b/src/importers/file_asset_importer.cpp index b5f1558..935aad3 100644 --- a/src/importers/file_asset_importer.cpp +++ b/src/importers/file_asset_importer.cpp
@@ -33,7 +33,8 @@ // If we have a file asset loader, lets give it the opportunity to claim responsibility for // loading the asset - if (m_FileAssetLoader != nullptr && m_FileAssetLoader->loadContents(*m_FileAsset, bytes)) + if (m_FileAssetLoader != nullptr && + m_FileAssetLoader->loadContents(*m_FileAsset, bytes, m_Factory)) { return StatusCode::Ok; }
diff --git a/test/image_asset_test.cpp b/test/image_asset_test.cpp index a05b526..5c86ef4 100644 --- a/test/image_asset_test.cpp +++ b/test/image_asset_test.cpp
@@ -47,7 +47,7 @@ rive::NoOpFactory gEmptyFactory; std::string filename = "../../test/assets/out_of_band/walle.riv"; - rive::RelativeLocalAssetLoader loader(filename, &gEmptyFactory); + rive::RelativeLocalAssetLoader loader(filename); auto file = ReadRiveFile(filename.c_str(), &gEmptyFactory, &loader);
diff --git a/test/in_band_asset_load_test.cpp b/test/in_band_asset_load_test.cpp index 29eb716..e0ea22e 100644 --- a/test/in_band_asset_load_test.cpp +++ b/test/in_band_asset_load_test.cpp
@@ -23,7 +23,9 @@ public: rive::FileAsset* attemptedAsset; - bool loadContents(rive::FileAsset& asset, rive::Span<const uint8_t> inBandBytes) override + bool loadContents(rive::FileAsset& asset, + rive::Span<const uint8_t> inBandBytes, + rive::Factory* factory) override { attemptedAsset = &asset; return true; @@ -36,7 +38,9 @@ public: rive::FileAsset* attemptedAsset; - bool loadContents(rive::FileAsset& asset, rive::Span<const uint8_t> inBandBytes) override + bool loadContents(rive::FileAsset& asset, + rive::Span<const uint8_t> inBandBytes, + rive::Factory* factory) override { return false; }