Repository navigation
Preserve coroutine Job in generated async bridge R8 rules - #294
Merged
Merged
Conversation
marcprux
approved these changes
Oct 7, 2026
marcprux
left a comment
Member
There was a problem hiding this comment.
Ack! Proguard/R8 strikes again.
Member
|
I wonder if the |
Removed comment about Async bridge JNI signatures referencing kotlinx.coroutines.Job.
BridgedJob.cancel looks up kotlinx.coroutines.Job.cancel(CancellationException) over JNI when the awaiting Swift task is cancelled. Keeping only the interface name lets R8 rename or remove cancel, so the lookup fails and the force unwrap crashes minified apps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marcprux
approved these changes
Oct 11, 2026
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
Since Skip 1.9.13, generated async bridge JNI lookups include
Lkotlinx/coroutines/Job;in the method signature. In a minified app, R8 can rename that interface while the native signature remains unchanged. The lookup then fails, and the generated force unwrap crashes. Debug builds without minification do not expose the problem.Change
Add
-keep interface kotlinx.coroutines.Jobto the shareddefaultProguardContentsgenerator used for app and framework ProGuard files. Extend the native-app initialization test to check the emitted rule.The manual upgrade guidance is added directly to the existing ProGuard documentation in skiptools/skip.dev#26.
Related: skiptools/skip-bridge#85 (diagnostics for failed bridge lookups).
Validation
swift test --filter SkipCommandTests: 21 tests passed.Jobmapped tokotlinx.coroutines.aandGetMethodID(..., "callback_fetch", "()Lkotlinx/coroutines/Job;")failed withNoSuchMethodError; with the rule,Jobretained its name and the lookup succeeded. This exercised a real JNI lookup against R8 classfile output, not an Android-device end-to-end test.git diff --checkpassed.