Skip to content

Bind Xamarin.AndroidX.Compose.Foundation MutationInterruptedException#1458

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-mutationinterruptedexception-bug
Open

Bind Xamarin.AndroidX.Compose.Foundation MutationInterruptedException#1458
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-mutationinterruptedexception-bug

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 7, 2026

androidx.compose.foundation.MutationInterruptedException — the exception Compose throws into await-able state-mutation APIs (e.g. ScrollState.animateScrollTo, LazyListState.animateScrollToItem) when a higher-priority MutatorMutex caller wins mid-flight — was silently dropped during binding, forcing C# callers to over-catch with Java.Lang.Throwable.

Root cause

Although both MutationInterruptedException (public final) and its parent internal.PlatformOptimizedCancellationException (public abstract) are public in the JAR, class-parse misreads the Kotlin metadata and emits visibility="private" for both, so the generator drops them. The parent was never bound either (only its _jvmAndAndroidKt helper), leaving the subclass without a chainable base type.

Changes

  • foundation-android/Transforms/Metadata.xml: add <attr name="visibility">public</attr> for both MutationInterruptedException and internal.PlatformOptimizedCancellationException, restoring the parent base type so the subclass binds naturally.
  • PublicAPI.Unshipped.txt: add the surfaced types/members (parent class + 4 ctors, child class + ctor, and their override accessors).
  • config.json: bump Xamarin.AndroidX.Compose.Foundation / .Android nugetVersion 1.11.2.11.11.2.2.

Both target namespaces already exist in published-namespaces.txt, so no namespace changes were needed.

This lets callers catch the exception by type:

try
{
    await scrollState.AnimateScrollToAsync(targetValue, ct);
}
catch (MutationInterruptedException)
{
    // gesture or higher-priority mutation won; ignore
}

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MutationInterruptedException binding issue in Xamarin.AndroidX.Compose.Foundation Bind Xamarin.AndroidX.Compose.Foundation MutationInterruptedException Jun 7, 2026
Copilot AI requested a review from jonathanpeppers June 7, 2026 21:01
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 7, 2026 22:24
Copilot AI review requested due to automatic review settings June 7, 2026 22:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Compose Foundation binding gap where androidx.compose.foundation.MutationInterruptedException (and its base androidx.compose.foundation.internal.PlatformOptimizedCancellationException) were being dropped due to mis-read Kotlin metadata visibility, preventing C# consumers from catching the exception by type.

Changes:

  • Forces both exception types’ visibility to public via foundation-android Metadata.xml so they are emitted by the generator.
  • Updates PublicAPI.Unshipped.txt to reflect the newly surfaced public surface area.
  • Bumps the NuGet revision for the Xamarin.AndroidX.Compose.Foundation and .Android packages to publish the binding change.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
source/androidx.compose.foundation/foundation-android/Transforms/Metadata.xml Adds visibility=public overrides for the two Compose exception classes so they bind and can be caught from C#.
source/androidx.compose.foundation/foundation-android/PublicAPI/PublicAPI.Unshipped.txt Records the newly exposed exception types/constructors/overrides in the public API tracking file.
config.json Bumps NuGet revision to ship the restored API surface.

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.

Xamarin.AndroidX.Compose.Foundation: MutationInterruptedException is dropped during binding

3 participants