Skip to content

[Auth] MSAL Platform specific code does not work in SkiaRenderer mode #20601

Closed

Description

@jeromelaban

Current behavior

Similar to #20439, the support for android/ios is not properly included when running outside the samples app.

Expected behavior

No response

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

Adding this line in the app works around the issue:

(builder as PublicClientApplicationBuilder)?.WithParentActivityOrWindow(() => ContextHelper.Current as Android.App.Activity);

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Renderer

  • Skia
  • Native

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    on May 27, 2025
  2. removed
    triage/untriaged
    difficulty/tbd
    on May 27, 2025
  3. added theissue type on Jun 20, 2025
  4. removed
    kind/bug
    on Jun 22, 2025
  5. changed the title [-][MSAL] Platform specific code does not work in SkiaRenderer mode[/-] [+][Auth][MSAL] Platform specific code does not work in SkiaRenderer mode[/+] on Nov 25, 2025
  6. changed the title [-][Auth][MSAL] Platform specific code does not work in SkiaRenderer mode[/-] [+][Auth] Platform specific code does not work in SkiaRenderer mode[/+] on Jan 13, 2026
  7. github-actions commented on May 14, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  8. added
    stale
    on May 14, 2026
  9. removed
    stale
    on May 14, 2026
  10. kazo0 commented on Aug 12, 2026

    @kazo0
    Contributor

    Did a full root-cause pass on this. Summary up front: the #if blocks in the add-in are not the problem — they compile correctly. The platform-specific Uno.UI.MSAL.dll is built and shipped in the package, but never deployed. Under SkiaRenderer, the runtime-asset swap replaces it with the no-op skia flavor on every head, including WebAssembly.

    Environment

    Uno.Sdk 6.8.0-dev.10
    Uno.WinUI / Uno.WinUI.MSAL 6.8.0-dev.21
    Microsoft.Identity.Client 4.87.0
    .NET SDK 10.0.103 (macOS)
    TFMs net10.0-android;net10.0-ios;net10.0-browserwasm;net10.0-desktop
    UnoFeatures SkiaRenderer

    Evidence: every head gets the same assembly

    SHA-256 of the Uno.UI.MSAL.dll variants in the package, against what actually lands in the app output:

    # package
    b3bfcb7e…  lib/net10.0-android/Uno.UI.MSAL.dll          ← has WithParentActivityOrWindow
    6ddd41b7…  lib/net10.0-ios26.0/Uno.UI.MSAL.dll          ← has WithParentActivityOrWindow
    3f6b1990…  uno-runtime/net10.0/webassembly/…            ← has WasmWebUi / WithCustomWebUi
    9db30a28…  lib/net10.0/Uno.UI.MSAL.dll                  ← no-op reference
    6e8f70f3…  uno-runtime/net10.0/skia/Uno.UI.MSAL.dll     ← no-op
    
    # app output
    6e8f70f3…  bin/Debug/net10.0-ios/iossimulator-arm64/Uno.UI.MSAL.dll
    6e8f70f3…  obj/Debug/net10.0-android/android/assets/arm64-v8a/Uno.UI.MSAL.dll
    6e8f70f3…  bin/Debug/net10.0-browserwasm/Uno.UI.MSAL.dll
    6e8f70f3…  bin/Debug/net10.0-desktop/Uno.UI.MSAL.dll
    

    All four resolve to the skia no-op. Disassembling AbstractApplicationBuilderExtensions.WithUnoHelpers:

    flavor body
    lib/net10.0-android WithParentActivityOrWindow(() => ContextHelper.Current)
    lib/net10.0-ios26.0 WithParentActivityOrWindow(() => UIApplication.SharedApplication.KeyWindow.RootViewController)
    uno-runtime/…/skia (deployed) ldarg.0; ret

    So MSAL is left with no parent activity / view controller, and AcquireTokenInteractive has nothing to attach to.

    Root cause

    Under SkiaRenderer, mobile heads carry a two-axis identifier (verified via -getProperty):

    net10.0-android → UnoUIRuntimeIdentifier=Skia, UnoWinRTRuntimeIdentifier=Android
    net10.0-ios     → UnoUIRuntimeIdentifier=Skia, UnoWinRTRuntimeIdentifier=iOS
    net10.0-desktop → UnoRuntimeIdentifier=Skia
    

    ReplaceUnoRuntime (uno.winui.runtime-replace.targets) passes both to RuntimeAssetsSelectorTask, which decides per-assembly whether to take the native lib/ asset or the uno-runtime/<tfm>/skia one. That decision is IsWinRTAssembly, and decompiled it is a hardcoded allowlist of three names:

    private bool IsWinRTAssembly(string fileNameWithoutExtension)
    {
        var s = fileNameWithoutExtension.ToLower(CultureInfo.InvariantCulture);
        return s is "uno" or "uno.ui.dispatching" or "uno.foundation";
    }

    Only those three take the GetWinRTAssembly path back out to lib/net10.0-<winrt-rid>*. Everything else — including Uno.UI.MSAL — gets the skia flavor.

    There is no opt-in for add-in packages. UnoRuntimeEnabledPackage only carries PackageBasePath:

    <UnoRuntimeEnabledPackage Include="Uno.WinUI.MSAL" PackageBasePath="$(MSBuildThisFileDirectory)" ... />

    which means this cannot be fixed by repackaging Uno.WinUI.MSAL alone. Any add-in shipping platform-flavored lib/ assets alongside a uno-runtime folder has the same problem.

    WebAssembly is affected too, not just Android/iOS

    browserwasm also deploys the skia no-op rather than uno-runtime/net10.0/webassembly (3f6b1990…), which is where WasmWebUi, WithCustomWebUi and WithHttpClientFactory live. Confirmed in the shipped webcil — the only relevant symbol present is WithUnoHelpers:

    $ strings Uno.UI.MSAL.<hash>.wasm | grep -E "WasmWebUi|ICustomWebUi|WithCustomWebUi|WithUnoHelpers"
    WithUnoHelpers
    

    So under SkiaRenderer the WASM popup flow is gone as well. That flavor is only selected by the legacy renderer.

    Secondary finding: WASM gets no Uno constants at all

    Actual symbols reaching the compiler (-t:GenerateAssemblyInfo -getProperty:DefineConstants):

    head present absent
    net10.0-android ANDROID, __UNO__, __UNO_SKIA__, __UNO_SKIA_ANDROID__, HAS_UNO_SKIA __ANDROID__
    net10.0-ios IOS, __IOS__, __UNO__, __UNO_SKIA__, __UNO_SKIA_APPLE_UIKIT__ __APPLE_UIKIT__
    net10.0-browserwasm BROWSERWASM, NET only __WASM__, __UNO__, and every HAS_UNO_*

    The browserwasm row looks wrong independently of this issue — no __UNO__ and no HAS_UNO_SKIA under SkiaRenderer. Consistent with #20875 and #17684. Worth confirming separately.

    It also means the documented app-level workaround needs platform-correct guards: #if ANDROID / #elif IOS work, but #if __ANDROID__ / #elif __APPLE_UIKIT__ (matching the add-in's own source) silently compile to nothing in a consumer app.

    Proposed fix

    The MAUI Embedding fix for the same root cause (#20439 → unoplatform/uno.extensions#2788) sidestepped the allowlist entirely, and is a good template:

    1. Move the platform implementations behind an interface in the neutral assembly
    2. Ship a satellite package — Uno.Extensions.Maui.WinUI.Runtime.Skia, multi-targeting net9.0-android;net9.0-ios;net9.0-maccatalyst with UnoFeatures=SkiaRenderer — supplying the implementation
    3. Resolve it at runtime

    Applied here that's a Uno.WinUI.MSAL.Runtime.Skia-style package, whose assemblies are picked by ordinary TFM resolution and never touch RuntimeAssetsSelectorTask. Naming precedent already exists with Uno.WinUI.Runtime.Skia.Android / .AppleUIKit.

    The alternative — giving IsWinRTAssembly an extensibility point, e.g. <UnoRuntimeEnabledPackage ... WinRTFlavoredAssemblies="Uno.UI.MSAL" /> — is a smaller change and would fix every add-in in this position at once, but is a Uno.UI.Tasks change rather than an add-in one.

    Either way WASM needs handling explicitly: there is currently no flavor of Uno.UI.MSAL that provides ICustomWebUi to a Skia-rendered browser head.

    App-level workaround (current packages)

    Replacing .WithUnoHelpers() on the builder works today, because app code still compiles against the native TFM:

    _app = PublicClientApplicationBuilder
        .Create(clientId)
        .WithAuthority(AzureCloudInstance.AzurePublic, tenant)
        .WithRedirectUri(redirectUri)
    #if ANDROID
        .WithParentActivityOrWindow(() => ContextHelper.Current as Android.App.Activity)
    #elif IOS
        .WithParentActivityOrWindow(() => UIKit.UIApplication.SharedApplication?.KeyWindow?.RootViewController)
    #endif
        .Build();

    Uno.dll is on the IsWinRTAssembly allowlist, so ContextHelper resolves to the real Android implementation. No equivalent workaround exists for WASM without hand-writing an ICustomWebUi.

  11. changed the title [-][Auth] Platform specific code does not work in SkiaRenderer mode[/-] [+][Auth] MSAL Platform specific code does not work in SkiaRenderer mode[/+] on Aug 12, 2026
  12. added a commit that references this issue on Aug 13, 2026
    0cc9dfe
  13. added a commit that references this issue on Aug 22, 2026
    1531ad7
  14. khaskoul commented on Aug 24, 2026

    @khaskoul

    Fix verified in 6.7.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions