Open Closed

Maui Blazor hybrid - White screen on AbpInitialization #9883


User avatar
0
aziz.bouhejba created

ABP Framework Version: 9.2 Project Type: Microservices template with MAUI Blazor Hybrid app Platform: Android (Samsung devices) Affected Models: S21 FE, S24 (consistently reproducible)

Issue: Application displays white screen and crashes when battery optimization is enabled

Root Cause: Samsung's aggressive battery optimization appears to block network requests during app resume, causing ABP module initialization to fail when attempting to fetch application configuration.

Reproduction Steps:

  1. Set app battery settings to "Optimized" or "Restricted"
  2. Launch app and complete login
  3. Close app without logging out (background the app)
  4. Reopen the app

Expected Result: App resumes normally with existing session Actual Result: White screen with AbpInitializationException

Key Error: Java.Net.UnknownHostException: Unable to resolve host "localhost"

Attempted Solutions:

  • Implemented Polly retry policies following https://abp.io/docs/latest/framework/api-development/dynamic-csharp-clients#retry-failure-logic-polly-integration

Business Impact:

  • Samsung devices represent significant market share
  • Default battery optimization settings cause app failure
  • Users experience appears broken after backgrounding

Potential Solutions Needed:

  1. Graceful handling of network failures during module initialization
  2. Option to skip/defer configuration refresh on app resume
  3. Better error handling for battery optimization scenarios
  4. Guidance for Samsung-specific battery whitelist recommendations

Additional Context:

  • Issue is specific to Samsung devices with battery optimization
  • Other Android manufacturers not affected
  • Problem occurs during MauiBlazorCachedApplicationConfigurationClient.InitializeAsync()

Full exception

[2025-09-11 13:28:41] Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.AspNetCore.Components.MauiBlazor.AbpAspNetCoreComponentsMauiBlazorModule, Volo.Abp.AspNetCore.Components.MauiBlazor, Version=9.2.0.0, Culture=neutral, PublicKeyToken=null: An error occurred during the ABP remote HTTP request. (Connection failure) See the inner exception for details.. See the inner exception for details. ---> Volo.Abp.Http.Client.AbpRemoteCallException: An error occurred during the ABP remote HTTP request. (Connection failure) See the inner exception for details. ---> System.Net.Http.HttpRequestException: Connection failure ---> Java.Net.UnknownHostException: Unable to resolve host "localhost": No address associated with hostname ---> Java.Lang.RuntimeException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)

--- End of managed Java.Lang.RuntimeException stack trace --- android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Linux.android_getaddrinfo(Native Method) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:133) at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:222) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:133) at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) at java.net.InetAddress.getAllByName(InetAddress.java:1152) at com.android.okhttp.Dns$1.lookup(Dns.java:41) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:178) at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:144) at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:86) at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:176) at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128) at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:90) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:30)


3 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • To handle network failures during ABP module initialization in a MAUI Blazor Hybrid app (especially on Samsung devices with aggressive battery optimization), you should implement a more resilient initialization and error handling strategy. The ABP initialization process expects a successful remote configuration fetch; if the network is unavailable (as with Samsung's battery optimization), it will throw an exception and show a white screen.

    • Here are recommended approaches:

    1. Graceful Network Failure Handling

      • Wrap the ABP initialization (especially the call to MauiBlazorCachedApplicationConfigurationClient.InitializeAsync()) in a try-catch block.
      • If a network error occurs, display a user-friendly message or a retry button, rather than allowing the app to crash or hang on a white screen.
      • Optionally, implement a retry/backoff policy using Polly, but ensure you do not block the UI thread or create an infinite loop.
    2. Defer or Skip Configuration Refresh

      • On app resume, check for network connectivity before attempting to refresh the configuration.
      • If the network is unavailable, skip the refresh and allow the app to use cached configuration, if available.
      • You can use Xamarin.Essentials/MAUI Essentials Connectivity.NetworkAccess to check network status.

      Example:

    if (Connectivity.NetworkAccess == NetworkAccess.Internet)
       {
           await MauiBlazorCachedApplicationConfigurationClient.InitializeAsync();
       }
       else
       {
           // Show offline message or use cached data
       }
    
    1. Custom Error UI

      • Implement a fallback UI for initialization errors. For example, show a dialog with "Retry" and "Exit" options if initialization fails due to network issues.
    2. Samsung Battery Optimization Guidance

      • Inform users about battery optimization issues and provide instructions to whitelist your app in Samsung's battery settings.
      • You can direct users to: Settings > Apps > [Your App] > Battery > Unrestricted.
    3. Avoid Using "localhost" in Production

      • The error Unable to resolve host "localhost" suggests the app is trying to connect to a local server, which will not work on a physical device. Ensure your RemoteService:BaseUrl and OIDC Authority point to a reachable server, not localhost.
    4. Polly Integration

      • ABP supports Polly for retry logic on HTTP client proxies. However, this does not help if the network is completely unavailable or if the device is blocking all requests. Use Polly for transient errors, but always check for connectivity first.

      Reference: ABP Polly Integration

    5. Session Persistence

      • Ensure your authentication/session tokens are persisted securely so that the user does not need to re-login after a failed resume.

    By combining these strategies, you can provide a much better user experience and avoid white screens or crashes due to Samsung's battery optimization.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    aziz.bouhejba created

    Tried all of these solutions, the only one we didn't try is // Show offline message or use cached data

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The app needs to retrieve remote data (MauiBlazorCachedApplicationConfigurationClient) during startup.

    Unable to resolve host "localhost": No address associated with hostname

    This seems to be a DNS problem.

    Can you try to override the MauiBlazorCachedApplicationConfigurationClient service to catch the exception and try again?

    https://github.com/abpframework/abp/blob/e6a51b14104fc9a8a95406e93397160873e306b6/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCachedApplicationConfigurationClient.cs#L56-L91

    Thanks.

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 10, 2025, 06:30