Repository navigation
[Android] Don't start a null intent from WebAuthenticatorIntermediateActivity - #39194
MykhailoDav wants to merge 2 commits into
Conversation
…xtras Without the fix, OnResume calls StartActivity(null), which throws a NullPointerException (dotnet#32000). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Activity When the activity is created without extras, OnCreate returns before it reads the authentication intent, and OnResume then called StartActivity(null), which crashed the app with a NullPointerException. Finish the activity instead, since there's nothing to start. Fixes dotnet#32000 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39194Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39194" |
|
Hey there @@MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Hey there @MykhailoDav! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Note 🔍
|
|
Thank you, @kubaflo , for your kind words! My other open PRs, #39181, #39183 and #39193, still apply to |
AI Review Summary
🗂️ Review Sessions — click to expand🚦 Gate — Test Before & After FixGate Result: ✅ PASSEDPlatform: ANDROID · Base: main · Merge base:
🔴 Without fix — 📱 WebAuthenticatorIntermediateActivity_Tests (StartingWithoutExtrasFinishesTheActivity): FAIL ✅ · 480s(no coded error found; showing last 1200 chars) 🟢 With fix — 📱 WebAuthenticatorIntermediateActivity_Tests (StartingWithoutExtrasFinishesTheActivity): PASS ✅ · 363s(no coded error found; showing last 1200 chars) 📁 Fix files reverted (1 files)
📋 Pre-Flight — Context & ValidationThe Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase. Next step: re-comment 🔬 Code Review — Deep AnalysisThe Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase. Next step: re-comment 🛠️ Try-Fix — Analysis & ComparisonThe Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase. Next step: re-comment 🏁 Report — Final RecommendationThe Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase. Next step: re-comment 📱 UI Tests — Button,Label,LayoutDetected UI test categories:
🧪 UI Test Execution Results (deep, platform pool)
|
Description of Change
On Android,
WebAuthenticatorIntermediateActivitycrashes the app when it's created without extras:The issue has crash reports from 9.0.110 and .NET 10. #24692 and #30414 reported the same crash.
Root cause
OnCreatereturns early when there are no extras (bothsavedInstanceStateandIntent.Extrasare null), soactualIntentstays null andlaunchedstays false.OnResumethen callsStartActivity(actualIntent)with null.Fix
In
OnResume, ifactualIntentis null on the first launch, the activity finishes instead of callingStartActivity. The check is where the crash happens, so it covers both waysactualIntentcan be null: no extras at all, and extras without the intent.Other paths are unchanged. An activity started by
WebAuthenticatorIntermediateActivity.StartActivityalways has the intent. WhenWebAuthenticatorCallbackActivitystarts the activity again, it passesLaunchedExtra, so the callback branch still runs.net11.0rewrote this activity, and the rewrite finishes when there are no extras. So this change is only needed onmain.IntermediateActivity, which the pickers use, has the same pattern inOnCreate(StartActivityForResult(actualIntent, …)), but no crash has been reported for it, so it isn't changed here.Tests
WebAuthenticatorIntermediateActivity_Tests.StartingWithoutExtrasFinishesTheActivity(Essentials.DeviceTests, Android) starts the activity without extras and waits for it to be destroyed. Android callsOnResume, so an exception thrown there would crash the test app. The test catches it withAndroidEnvironment.UnhandledExceptionRaiserinstead, so it fails with an assertion.StartingWithoutExtrasFinishesTheActivityNullPointerExceptionfromStartActivityinWebAuthenticatorIntermediateActivity.OnResume, and the activity stays openWith the fix, all 283 Essentials.DeviceTests pass on an API 37 emulator.
Issues Fixed
Fixes #32000