Repository navigation
fix(svg-android): link libc++ statically so libcanvassvg.so loads - #291
Merged
Merged
Conversation
…hout libc++_shared
stb_image is built with cc-rs, whose Android default emits -lc++_shared.
Depending on link resolution, libcanvassvg.so picked up a NEEDED
libc++_shared.so (as in the published 3.0.22 AAR), which no AAR ships, so
System.loadLibrary("canvassvg") failed and NSCSVG was unavailable.
Set CXXSTDLIB_<triple>=c++_static in the Android build scripts (svg and
canvas) and rebuild the canvas-svg AAR.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
ℹ️ Note: npm publishing is disabled for pull requests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The published
@nativescript/canvas-svgAAR'slibcanvassvg.so(every ABI) hasNEEDED libc++_shared.so, and no AAR ships that library.System.loadLibrary("canvassvg")inNSCSVG's static init fails, so apps report "NSCSVG constructor not found".Cause
stb_image(pulled in throughcanvas-core) builds C++ with cc-rs. On Android, cc-rs linksc++_sharedby default. Skia linksc++_static, so whether the shared lib ends up in NEEDED depends on how the link resolves.libcanvasnative.sohappens to resolve to the static copy; the CI-builtlibcanvassvg.sodoesn't.Fix
build-svg-android.shandbuild-android.shsetCXXSTDLIB_<triple>=c++_static, so every cc-rs crate links libc++ statically.canvassvg-release.aarand the jniLibs for all four ABIs.Verification
llvm-readelf -d:libcanvassvg.sofor arm64-v8a, armeabi-v7a, x86 and x86_64 now needs onlyliblog,libandroid,libjnigraphics,libEGL,libGLESv2,libc,libmandlibdl. The.sofiles in the canvas, audio-context and polyfill AARs don't needlibc++_sharedeither.libc++_shared.soin the APK.libcanvassvg.soloads and the canvas-svg demo renders.