Skip to content

fix(svg-android): link libc++ statically so libcanvassvg.so loads - #291

Merged
triniwiz merged 1 commit into
masterfrom
fix/svg-android-libcxx
Nov 27, 2026
Merged

triniwiz merged 1 commit into
masterfrom
fix/svg-android-libcxx

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Problem

The published @nativescript/canvas-svg AAR's libcanvassvg.so (every ABI) has NEEDED libc++_shared.so, and no AAR ships that library. System.loadLibrary("canvassvg") in NSCSVG's static init fails, so apps report "NSCSVG constructor not found".

Cause

stb_image (pulled in through canvas-core) builds C++ with cc-rs. On Android, cc-rs links c++_shared by default. Skia links c++_static, so whether the shared lib ends up in NEEDED depends on how the link resolves. libcanvasnative.so happens to resolve to the static copy; the CI-built libcanvassvg.so doesn't.

Fix

  • build-svg-android.sh and build-android.sh set CXXSTDLIB_<triple>=c++_static, so every cc-rs crate links libc++ statically.
  • Rebuilt canvassvg-release.aar and the jniLibs for all four ABIs.

Verification

  • llvm-readelf -d: libcanvassvg.so for arm64-v8a, armeabi-v7a, x86 and x86_64 now needs only liblog, libandroid, libjnigraphics, libEGL, libGLESv2, libc, libm and libdl. The .so files in the canvas, audio-context and polyfill AARs don't need libc++_shared either.
  • Ran the demo app on a Pixel 9 Pro emulator (arm64) with no libc++_shared.so in the APK. libcanvassvg.so loads and the canvas-svg demo renders.

…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.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b2eda313-ccb3-4b61-b247-adf189471b83

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@triniwiz
triniwiz merged commit 7c2ad2f into master Nov 27, 2026
33 checks passed
@triniwiz
triniwiz deleted the fix/svg-android-libcxx branch November 27, 2026 13:42
@github-actions

Copy link
Copy Markdown

ℹ️ Note: npm publishing is disabled for pull requests.
Publishing is performed only from tag pushes via the npm Release workflow.
If you need a test publish, merge to master — pushes publish pr-tagged prereleases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant