Skip to content

build: bump backend, duplicating the backend library on disk - #22670

Merged
mikehardy merged 4 commits into
ankidroid:mainfrom
david-allison:backend-bump-classloader
Oct 22, 2026
Merged

mikehardy merged 4 commits into
ankidroid:mainfrom
david-allison:backend-bump-classloader

Conversation

@david-allison

@david-allison david-allison commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Note

Assisted-by: Claude Opus 5 - original gradle script
Assisted-by: GPT-6-Astra xhigh - reviewed, rewrote & tested it

Purpose / Description

By duplicating the backend library on disk, we allow support for multiple classloaders.

As these libraries are persistent (but hashed) on-disk, we need a utility to inform developers that old versions are taking up space.

Now this is implemented, we then start improving tests to move them away from Robolectric.

Fixes

Approach

How Has This Been Tested?

Performance: we're likely only looking at 5s of difference, this mostly exists to fix various test-related frustrations and flakes.

./gradlew :AnkiDroid:testFullDebugUnitTest --rerun -PbackendTempLibraryWarnBytes=0 --console=plain

> Task :AnkiDroid:testFullDebugUnitTest FAILED
> Task :AnkiDroid:finalizeTestRoborazziFullDebug SKIPPED
Anki backend test libraries are using 244.5 MiB (5 files):
    46.0 MiB  /private/var/folders/ym/nqynp93d4j74dpzw20sq4wq00000gn/T/librsdroid-30a774fd156c9b354bab88ebbb62748eebfbd2a6-1.dylib
    46.0 MiB  /private/var/folders/ym/nqynp93d4j74dpzw20sq4wq00000gn/T/librsdroid-30a774fd156c9b354bab88ebbb62748eebfbd2a6-2.dylib
    46.0 MiB  /private/var/folders/ym/nqynp93d4j74dpzw20sq4wq00000gn/T/librsdroid-30a774fd156c9b354bab88ebbb62748eebfbd2a6.dylib
    60.7 MiB  /private/var/folders/ym/nqynp93d4j74dpzw20sq4wq00000gn/T/librsdroid-be836b4f2ce70bd1d2cf36a27d8da6d1d3b44872.dylib
    46.0 MiB  /private/var/folders/ym/nqynp93d4j74dpzw20sq4wq00000gn/T/librsdroid-f1a104ccb1b574fff5839a70fbb478551c1fc8fc.dylib
rsdroid-testing keeps an original and up to five copies per checksum by default, for reuse across classloaders.
By default these files live outside the project and are not removed by Gradle clean.
To reclaim space, stop tests in all checkouts and IDEs, then delete the listed library files.
Needed libraries will be extracted again on the next test run. Leave .lock files in place.

Learning

I had a longer writeup, but forgot to submit it last night :/

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Update the backend to 0.1.72-anki26.09.3

Independent JVM and Robolectric classloaders can now call
the native backend in the same process.

This is done by duplicating the backend library. A warning is added
when the retained test libraries exceed 1 GiB

Fixes 14796
Related to https://redirect.github.com/ankidroid/Anki-Android-Backend/pull/713

Assisted-by: Claude Opus 5 - original gradle script
Assisted-by: GPT-6-Astra xhigh - reviewed, rewrote & tested it
Assisted-by: GPT-6.1-Sol xhigh
`RobolectricTestParameterInjector` can be used now the backend supports multiple classloaders.

Part of 14796

Assisted-by: GPT-6-Astra xhigh
Now we can have multiple classloaders loading the backend, run more
tests without Android dependencies

`EmptyApplication` is also used where possible.

Temp folder/coroutine setup us replaced with scoped rules

Typed Answer tests are now split into Android/Non-Android

Part of 14796

Assisted-by: GPT-6-Astra xhigh
For why some tests unexpectedly still need `@RunsWith/RobolectricTest`
and the work we should do to avoid it.

Related to 14796

Assisted-by: GPT-6-Astra xhigh
@david-allison
david-allison force-pushed the backend-bump-classloader branch from 70f4d59 to 299f6c8 Compare October 21, 2026 20:58

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assisted-by: grok-4.7-medium

Thanks — the per-classloader backend copy and the temp-dir warning look right for the mixed Jvm/Robolectric suite.

Replayed four commits onto current main without pushing (PRE_TIP 299f6c8f). Local buildSrc, lint/CQ, full unit, and playRelease emulator on API 36 (emulator-5554 / API36_GAPI_PS16K) passed.

Backend 0.1.72 loads a separate native library file per classloader, Robolectric always runs ensureSetup(), and the Gradle report warns when temp rsdroid copies exceed the configured threshold.

@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Review labels Oct 21, 2026
@mikehardy
mikehardy added this pull request to the merge queue Oct 21, 2026
@david-allison
david-allison removed this pull request from the merge queue due to a manual request Oct 22, 2026
@david-allison david-allison added Needs Second Approval Has one approval, one more approval to merge and removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) labels Oct 22, 2026
@david-allison

david-allison commented Oct 22, 2026 •

Copy link
Copy Markdown
Member Author

@ankidroid/reviewers - this is a potentially big one - deep review requested of the gradle change

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems fine on a read, and I don't think it'll get better with age
can always follow on...

@mikehardy
mikehardy added this pull request to the merge queue Oct 22, 2026
@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Oct 22, 2026
Merged via the queue into ankidroid:main with commit d937eeb Oct 22, 2026
30 checks passed
@github-actions github-actions Bot added this to the 2.26 release milestone Oct 22, 2026
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Oct 22, 2026
@david-allison
david-allison deleted the backend-bump-classloader branch October 22, 2026 04:10
ColbyCabrera pushed a commit to ColbyCabrera/Hirameki that referenced this pull request Oct 24, 2026
Upgrade Anki desktop backend to 26.09.3 and handle RELATIVE_OVERDUENESS enum.
Allows independent JVM and Robolectric classloaders to call the native backend.

Upstream-commits: b720d97128, c58a477a94, 5371107add
Upstream-PRs: `ankidroid/Anki-Android#22154`, `ankidroid/Anki-Android#22670`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants