Skip to content

[Bug] Embedded WebView login page shifts when Android keyboard appears (MAUI + MSAL 4.82, B2C, Android 16, Pixel 8) #5711

@melz30

Description

@melz30

Library version used

Microsoft.Identity.Client 4.82

.NET version

.Net9

Scenario

PublicClient - mobile app

Is this a new or an existing app?

None

Issue description and reproduction steps

When using MSAL with WithUseEmbeddedWebView(true) in a .NET MAUI app on Android, the B2C login page displayed by the embedded WebView shifts/moves when the soft keyboard appears. The rest of the MAUI app behaves correctly; the issue is specific to the MSAL embedded login activity.

When switching to WithUseEmbeddedWebView(false) (system browser / custom tab), the problem disappears completely.

This looks like an interaction between the embedded MSAL AuthenticationAgentActivity and the new Android window insets / IME behavior on recent Android versions (Android 16, Pixel 8).

Environment

Library : Microsoft.Identity.Client 4.82.0
Platform : .NET MAUI
Android devices :
Google Pixel 8 (Android 16);
Google Pixel 10 (Android 16);
B2C configuration with sign‑up/sign‑in policies.

Steps to reproduce

Create a .NET MAUI app for Android and configure MSAL with Azure AD B2C.
Use Microsoft.Identity.Client 4.82.0.
Configure AcquireTokenInteractive with .WithUseEmbeddedWebView(true) and .WithB2CAuthority(...) as shown above.
Build and run on a Pixel 8 (Android 16).
Trigger interactive sign‑in.
On the B2C login page, tap into the email or password field to show the soft keyboard.

Observed behavior

On the MSAL B2C login page (inside the embedded WebView), when the user taps into an input field (e.g. email/password) and the soft keyboard appears, the entire page “jumps” or shifts vertically.
The shift happens only in the MSAL AuthenticationAgentActivity. After returning to the MAUI app, all layouts are correct and stable.

The issue is reproducible with:

WindowSoftInputMode = SoftInput.AdjustResize;
WindowSoftInputMode = SoftInput.AdjustResize | SoftInput.StateHidden;
WindowSoftInputMode = SoftInput.AdjustPan;
WindowSoftInputMode = SoftInput.AdjustPan | SoftInput.StateHidden.
Changing the WindowSoftInputMode on MainActivity does not eliminate the problem; it only slightly changes how the jump looks.

The relevant logcat output when the keyboard shows looks like this (truncated) :

[InsetsController] show(ime())
[InsetsController] Setting requestedVisibleTypes to 511 (was 503)
[WindowOnBackDispatcher] setTopOnBackInvokedCallback (unwrapped): android.view.ImeBackAnimationController@71eca18
[VRI[AuthenticationAgentActivity]] WindowInsets changed: ime:[0,0,0,1027]
[ImeTracker] com.app:3605d3e7: onShown

Image Image Image

Relevant code snippets

I have a .NET MAUI app using MSAL with Azure AD B2C. For interactive sign‑in I am calling:

_authResult = await _publicClientApplication
    .AcquireTokenInteractive(_environmentConfigsService.ScopesSignUpSignInSecured)
    .WithUseEmbeddedWebView(true)
    .WithB2CAuthority(_environmentConfigsService.AuthoritySignUpSignInSecured)
    .WithExtraQueryParameters(GetExtraQueryParameters(false))
    .ExecuteAsync();

The Android MainActivity is configured as follows :

[Activity(
    Theme = "@style/CustomTheme.Splash",
    MainLauncher = true,
    ConfigurationChanges = ConfigChanges.ScreenSize 
                           | ConfigChanges.Orientation 
                           | ConfigChanges.UiMode 
                           | ConfigChanges.ScreenLayout 
                           | ConfigChanges.SmallestScreenSize 
                           | ConfigChanges.Density,
    WindowSoftInputMode = SoftInput.AdjustResize | SoftInput.StateHidden)]
public class MainActivity : MauiAppCompatActivity
{
}

My custom splash theme only sets the status bar color and inherits from the MAUI default splash theme :

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="CustomTheme.Splash" parent="Maui.SplashTheme">
    <item name="android:statusBarColor">#CEE2FF</item>
  </style>
</resources>

Expected behavior

  • When using WithUseEmbeddedWebView(true), the B2C login page should remain visually stable when the soft keyboard appears and disappears.
  • No noticeable jump or shift of the whole page should occur when focusing input fields.

Identity provider

Other

Regression

No response

Solution and workarounds

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions