Skip to content

[Android] Fix MediaPicker launcher disposal after garbage collection - #39710

Merged
kubaflo merged 3 commits into
dotnet:inflight/candidatefrom
sheiksyedm:fix-android-mediapicker-gc-39700
Oct 28, 2026
Merged

kubaflo merged 3 commits into
dotnet:inflight/candidatefrom
sheiksyedm:fix-android-mediapicker-gc-39700

Conversation

@sheiksyedm

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Bug description

When full managed and Java garbage collection occurs without a strong managed reference
to the activity—for example, from an AndroidX fragment—the registered launcher wrapper
can be disposed even though the native activity remains alive and resumed.

Subsequent picker calls fail with:

System.ObjectDisposedException:
Cannot access disposed object ...
AndroidX.Activity.Result.ActivityResultLauncherInvoker

The reporter reproduced this in MAUI 10.0.120 and identified 10.0.100 as working.
Both picker attempts fail, and the failure persists until the activity is recreated.

Root cause

ActivityForResultRequest<TContract, TResult> stores per-activity launchers in a
ConditionalWeakTable<ComponentActivity, ActivityResultLauncher>.

A value in this table is retained conditionally on its managed key's reachability.
Android keeping the native activity alive does not guarantee that the activity has a
strong managed root. During collection, the launcher wrapper can therefore become
eligible for finalization and lose its JNI handle while the native activity and its
result registrations are still valid.

Previously, the launcher was held in a strong field and was not exposed to this lifetime gap.

Fix

  • Replace the weak-key launcher table with a ConcurrentDictionary using reference equality.
  • Strongly retain each activity and its launcher until ActivityDestroyed.
  • Remove the registration at the beginning of ActivityDestroyed, including paths with no pending request.
  • Preserve independent per-activity requests, pending-request cancellation, and activity-recreation handling.

No public API changes are introduced.

Regression

PR #35944

Issues Fixed

Fixes #39700

kubaflo and others added 3 commits October 27, 2026 10:43
…he gallery (dotnet#39621)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Extend the existing MacCatalyst startup-page resolver to Android, iOS,
and Windows, and wire it into `_IssuesUITest` / `_GalleryUITest` so
fixtures and resets can launch directly to their issue or gallery page
instead of searching and tapping through the gallery.

- **Android, iOS, MacCatalyst:** direct fixture launch is enabled by
default. Driver sessions remain reusable; each fixture receives its own
startup target. Reset/retry paths retain the current target, and
teardown closes the app instead of launching an unused gallery. Gallery
subpage selection still runs after launch; the current Android CoreCLR
ShellSearch setup failure remains under investigation.
- **Windows:** startup arguments and fixture integration are
implemented, but direct fixture launch is **opt-in** with
`MAUI_UITEST_DIRECT_LAUNCH=true`. WinAppDriver cannot change
`appArguments` on an existing session, so changing targets requires a
new session. Keep the existing navigation default until native timing
proves this is a benefit.
- Set `MAUI_UITEST_DIRECT_LAUNCH=false` to compare legacy navigation.
Normal launches and missing/empty/unknown startup targets still open the
gallery; unknown targets emit a debug diagnostic.
- Preserve the internet-required issue check through the shared page
factory. Forward the configured Android UDID to Appium and escape launch
arguments.
- Starting a new Apple test target and resetting the app stop explicitly
when closing fails. **Correction in `10e3dc7d710`:** OS-command
fallbacks no longer return success for a missing process, timeout, or
nonzero exit code; redirected output is drained and failures are logged.
Reset checks the close result before relaunching. This closes the
reproduced gap where a failed `simctl terminate` command was incorrectly
reported as success.
- Add startup/lifecycle utility tests to the solution and Helix
unit-project list, plus cross-platform fixture/reset coverage. The
regression page records how many application windows existed during
construction: `0` demonstrates initial-page creation, while the legacy
gallery-navigation control observes `1`.

Manual startup examples (exact issue description or gallery title,
case-insensitive):

```bash
adb shell am start -S -n com.microsoft.maui.uitests/com.microsoft.maui.uitests.MainActivity --es test '"Direct test launch"'
SIMCTL_CHILD_test="Direct test launch" xcrun simctl launch --terminate-running-process <simulator-udid> com.microsoft.maui.uitests
```

```powershell
.\Controls.TestCases.HostApp.exe '--test=Direct test launch'
```

MacCatalyst continues using the app process's `test` environment
variable. Startup arguments are consumed during initial-window creation;
do not merely foreground an already-running process when changing
targets. This extends dotnet#31673's resolver rather than adding a competing
one.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes dotnet#32463

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

### Validation

#### Termination-fallback correction

- `dotnet test
src/TestUtils/tests/UITest.Appium.Tests/UITest.Appium.Tests.csproj
--filter
'FullyQualifiedName~FailedSimulatorFallbackCannotLaunchWithStaleStartupArguments'
-v:minimal` — **both new cases failed before the fix** with the intended
missing-exception assertion. They use a recording driver that rejects
termination and a real `simctl` command with an invalid simulator ID; no
simulator app or host UI is controlled.
- `dotnet test
src/TestUtils/tests/UITest.Appium.Tests/UITest.Appium.Tests.csproj
--no-restore -v:minimal` — **22 passed after the fix**. Includes the
original 19 utility tests, the two launch/reset regressions, and a
direct force-close response regression.
- `dotnet test
src/TestUtils/tests/UITest.Appium.Tests/UITest.Appium.Tests.csproj
--no-build -v:q` — **22 passed in each of two additional fresh test
processes**.

These utility tests establish the corrected fallback behavior, not
native Appium reliability or resolution of the outstanding UI failures.

#### Earlier implementation validation

The following checks were performed during the initial implementation,
before the later rebase onto `4781afbd`. They were **not rerun as native
certification of `10e3dc7d710`**.

Initial iOS validation used an isolated iPhone 11 Pro on iOS 26.5 with
`simctl` launches, screenshots, and local Vision OCR: all six startup
scenarios passed 3/3 (18 checks). Subsequently, with explicit permission
for simulator-only XCTest/WebDriverAgent,
`DEVICE_UDID=5668A696-15E3-41E8-884C-7D06EB167B07 dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter 'FullyQualifiedName~Issue32463Runner'` ran the
actual fixture: **2 passed**, covering direct startup and
tap/increment/reset. No host macOS UI automation was used. This does not
clear the current Stepper failures.

- `dotnet build ./Microsoft.Maui.BuildTasks.slnf -v:q` — passed.
- `dotnet build
src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj
-f net10.0-ios -p:RuntimeIdentifier=iossimulator-arm64 -v:q` — passed;
installed and locally validated as above using normal simulator signing.
- `dotnet build
src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj
-f net10.0-android -p:EmbedAssembliesIntoApk=true -v:q` — passed;
installed on an isolated headless API 34 emulator.
- `dotnet build
src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj
-f net10.0-maccatalyst -p:RuntimeIdentifier=maccatalyst-arm64 -v:q` —
passed; host UI automation was not run.
- `DEVICE_UDID=emulator-5556 dotnet test
src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj
--no-restore --filter
'FullyQualifiedName~Issue32463|FullyQualifiedName~Issue10222Test|FullyQualifiedName~VerifyButton_CommandAndCommandParameter'`
— **15 passed**, including existing issue/gallery fixtures, per-test
resets, and the legacy-navigation control.
- `dotnet build
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
-v:q` — passed.
- `dotnet build
src/Controls/tests/TestCases.Mac.Tests/Controls.TestCases.Mac.Tests.csproj
-v:q` — passed.
- `dotnet build
src/Controls/tests/TestCases.WinUI.Tests/Controls.TestCases.WinUI.Tests.csproj
-v:q` — passed. Windows native execution was not performed locally on
this macOS machine.
- `dotnet msbuild eng/helix.proj -getItem:XUnitProject -nologo` —
passed; includes the utility test project.

Earlier controlled runner verification:

```powershell
$env:AdbTarget = '-s emulator-5556'
$env:DEVICE_UDID = 'emulator-5556'
$DeviceUdid = 'emulator-5556'
& .github/skills/verify-tests-fail-without-fix/scripts/verify-tests-fail.ps1 -Platform android -TestType UITest -TestFilter 'FullyQualifiedName~Issue32463Runner' -FixFiles 'src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs' -BaseBranch 0796941 -PRNumber 39621 -RequireFullVerification
```

**`VERIFICATION PASSED`**: legacy fixture setup failed the intended
window-count assertion (`expected 0, actual 1`); restored direct-launch
setup passed both selected tests. The original Android host verification
also failed its three direct-launch cases without the host fix and
passed all six with it. These earlier checks are not substitutes for the
current native CI matrix.

### Measured performance (limited local sample)

Three interleaved legacy/direct runs of the same two existing Android
fixtures (`Issue10222Test` and
`VerifyButton_CommandAndCommandParameter`), each with 2/2 tests passing.
Compared full `dotnet test --no-build` wall time, including fixture
setup, with `MAUI_UITEST_DIRECT_LAUNCH=false` versus `true`:

| Mode | Run 1 | Run 2 | Run 3 | Median |
|---|---:|---:|---:|---:|
| Legacy navigation | 20.938s | 20.514s | 20.819s | 20.819s |
| Direct startup | 16.237s | 23.551s | 15.575s | 16.237s |

The median was **22.0% lower** in this sample; one direct run was
slower. This is not a suite-wide estimate or a claim of an iOS/Windows
speedup.

### CI observation and remaining gaps

**This PR is not runtime-green.** The following terminal builds tested
the preceding head `f09f1302a01` through merge `e00a7f22` on base
`4781afbd`; they do not validate the new termination correction.

- [Main validation
1649162](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1649162)
failed in Windows Debug: `MSB4024` while reading generated
`.buildtasks/Microsoft.Maui.Core.props`, which another process held
open. The exact-base main build passed, but that is not causal proof.
This failure is **not** the old `WMC0612` XAML error from the initial
implementation.
- [UI validation
1649164](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1649164)
failed. Its 85 failed result occurrences represent 73 distinct automated
test/platform names, not 85 independent defects. Thirty CoreCLR Android
ShellSearch outcomes share one fixture-setup timeout at
`_GalleryUITest.FixtureSetup:58`. Five iOS Stepper assertions persist.
Other assertion, timeout, app-not-running, and visual failures remain
unresolved; neither passing utility tests nor isolated passing native
cases clear them.
- Windows ShellSearch has same-base peer-failure observations, while
other Windows visuals have passing same-base cross-PR controls. Those
are observations, not proof of PR causality or clearance. Some Catalyst
Entry visual signatures also occur on main; remaining failures must not
be dismissed as unrelated.
- [Device validation
1649165](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1649165)
succeeded, using a different harness. It does not certify Appium fixture
lifecycle correctness.

A same-lane direct-launch-disabled control for the CoreCLR ShellSearch
failure has **not yet been performed**. Its source-bound artifact
confirms the requested startup target was sent, but diagnostics do not
establish why setup timed out. No assertions, screenshot goldens,
tolerances, or skips were changed to mask these failures.

---------

Copilot-Session: cdc98af7-0509-443d-8a84-cc75ecbc1a1e
Updated
[Microsoft.AspNetCore.Authentication.Facebook](https://github.com/dotnet/dotnet)
from 10.0.13 to 10.0.14.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Authentication.Facebook's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.AspNetCore.Authentication.Google](https://github.com/dotnet/dotnet)
from 10.0.13 to 10.0.14.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Authentication.Google's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.AspNetCore.Authentication.MicrosoftAccount](https://github.com/dotnet/dotnet)
from 10.0.13 to 10.0.14.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Authentication.MicrosoftAccount's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Keep per-activity result launchers strongly referenced until the activity is destroyed so managed and Java garbage collection cannot dispose a live activity's launcher.

Add device regression coverage for GC survival and launcher removal with and without a pending request.

Fixes dotnet#39700
Copilot AI balanced review requested due to automatic review settings October 27, 2026 16:59
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39710

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39710"

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Oct 27, 2026
@azure-pipelines

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The managed/native lifetime change needs confirmed Android device-test and CI results before human approval.

No open issues 🎉

What changed in this PR

Addresses Android MediaPicker regression #39700 by retaining each activity and its launcher until activity destruction, preventing garbage collection from disposing launchers prematurely.

Changes:

  • Replaces weak-key launcher storage with a reference-equality ConcurrentDictionary.
  • Removes launcher entries on activity destruction, even when no request is pending.
  • Adds Android device tests for launcher survival across garbage collection and removal on destruction.
File Description
src/​Essentials/​test/​DeviceTests/​Tests/​ActivityStateManagerRecreation_Tests.Android.cs Adds garbage-collection and activity-destruction regression tests.
src/​Essentials/​src/​Platform/​ActivityForResultRequest.android.cs Strongly retains per-activity launchers and removes them on destruction.

Review effort: Balanced

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 27, 2026
@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 0 findings

Reviewed commit 88efe49.

@MauiBot

MauiBot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@sheiksyedm — existing-test verification for commit 88efe499.

Result PASSED Platform Android Commit 88efe499


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

📱 Device tests
Test group Without fix With fix
ActivityStateManagerRecreation_Tests (RegisteredLauncher_SurvivesGarbageCollectionWithoutActivityRoot, DestroyedActiv... ✅ Failed as expected (490s) ✅ Passed (397s)
Execution log excerpts

Without fix ActivityStateManagerRecreation_Tests (RegisteredLauncher_SurvivesGarbageCollectionWithoutActivityRoot, DestroyedActiv...

Bytes": 8322998272
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.essentials.devicetests'..
info: Successfully uninstalled com.microsoft.maui.essentials.devicetests
XHarness exit code: 1 (TESTS_FAILED)
  Passed: 0
  Failed: 3
  Skipped: 0
  Total: 3
  Tests completed with exit code: 1

With fix ActivityStateManagerRecreation_Tests (RegisteredLauncher_SurvivesGarbageCollectionWithoutActivityRoot, DestroyedActiv...

        "totalMemoryBytes": 8322998272
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.essentials.devicetests'..
info: Successfully uninstalled com.microsoft.maui.essentials.devicetests
XHarness exit code: 0
  Passed: 3
  Failed: 0
  Skipped: 0
  Total: 3
  Tests completed successfully

PR head: 88efe499.

Without-fix baseline: b20099cf.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@sheiksyedm — test-failure analysis for commit 88efe49.

Scope CI failures Commit 88efe49


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

🧪 maui-pr-uitests

Matching non-Android diagnostics predate these Android-only changes. Android comparisons lack runtime provenance; bounded target history cannot clear unmatched cases.


🧭 Follow-up — actions and refresh

Next action: Restore unsampled task/Helix logs and runtime provenance; compare unresolved cases on identical main setup. Capture termination logs and inspect differing snapshots before attribution.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from main to inflight/candidate October 28, 2026 09:40
@kubaflo
kubaflo merged commit 676d108 into dotnet:inflight/candidate Oct 28, 2026
188 of 214 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR13 milestone Oct 28, 2026
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
…39710)

<!-- Please let the below note in for people that find this PR -->
   > [!NOTE]
   > Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
   
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Bug description

When full managed and Java garbage collection occurs without a strong
managed reference
to the activity—for example, from an AndroidX fragment—the registered
launcher wrapper
can be disposed even though the native activity remains alive and
resumed.

Subsequent picker calls fail with:

    System.ObjectDisposedException:
    Cannot access disposed object ...
    AndroidX.Activity.Result.ActivityResultLauncherInvoker

The reporter reproduced this in MAUI 10.0.120 and identified 10.0.100 as
working.
Both picker attempts fail, and the failure persists until the activity
is recreated.

### Root cause

`ActivityForResultRequest<TContract, TResult>` stores per-activity
launchers in a
`ConditionalWeakTable<ComponentActivity, ActivityResultLauncher>`.

A value in this table is retained conditionally on its managed key's
reachability.
Android keeping the native activity alive does not guarantee that the
activity has a
strong managed root. During collection, the launcher wrapper can
therefore become
eligible for finalization and lose its JNI handle while the native
activity and its
result registrations are still valid.

Previously, the launcher was held in a strong field and was not exposed
to this lifetime gap.

### Fix

- Replace the weak-key launcher table with a `ConcurrentDictionary`
using reference equality.
- Strongly retain each activity and its launcher until
`ActivityDestroyed`.
- Remove the registration at the beginning of `ActivityDestroyed`,
including paths with no pending request.
- Preserve independent per-activity requests, pending-request
cancellation, and activity-recreation handling.

No public API changes are introduced.

### Regression

PR #35944


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #39700

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copilot-Session: cdc98af7-0509-443d-8a84-cc75ecbc1a1e
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 28, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 88efe499 Deployed Oct 27, 2026 by sheiksyedm via conclusion #2542
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-essentials-mediapicker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] MediaPicker.PickPhotosAsync throws ObjectDisposedException ('ActivityResultLauncherInvoker') after a GC (regression in 10.0.110+)

4 participants