Activities of "aziz.bouhejba"

Hi thanks, we ended up waiting for internet connection to come back, it's definitely killed by some Samsung devices when battery is optimized so the ABP apps crashes for them because of the network dependency. This was our solution

using Microsoft.Extensions.Configuration;
using Volo.Abp;

namespace SampleProject.MauiBlazor;

public partial class App : Application
{
    private readonly IServiceProvider serviceProvider;
    private Page? rootPage;

    public App(IServiceProvider serviceProvider)
    {
        InitializeComponent();
        this.serviceProvider = serviceProvider;
        UserAppTheme = AppTheme.Light;
    }

    protected override Window CreateWindow(IActivationState? activationState)
    {
        rootPage = new MainPage();

        var window = new Window(rootPage);

        // Initialize asynchronously without blocking
        _ = Task.Run(async () =>
        {
            try
            {
                await WaitForNetworkConnectivityAsync();
                serviceProvider.GetRequiredService<IAbpApplicationWithExternalServiceProvider>().Initialize(serviceProvider);

                // Switch to main page on UI thread
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    window.Page = new MainPage();
                });
            }
            catch (Exception ex)
            {
                rootPage = new MainPage();
            }
        });

        return window;
    }

    private static async Task WaitForNetworkConnectivityAsync()
    {
        var connectivity = Connectivity.Current;
        var maxRetries = 30; // 30 seconds max wait
        var retryCount = 0;

        while (retryCount < maxRetries)
        {
            if (connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                if (await CanReachApiAsync())
                {
                    return;
                }
            }

            await Task.Delay(1000); // Wait 1 second
            retryCount++;
        }

        // Log warning or show user message about connectivity issues
        System.Diagnostics.Debug.WriteLine("Network connectivity timeout");
    }

    private static async Task<bool> CanReachApiAsync()
    {
        try
        {
            using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
            var response = await client.GetAsync("https://google.com");
            return response.IsSuccessStatusCode;
        }
        catch
        {
            return false;
        }
    }
}

I would recommend having something like this in the template because all Samsung devices will fail with an ABP template. we struggled with this issue for months because not everyone was able to reproduce it. 😬

Thanks again have a good day

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

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)

Thank you for the quick answer, very appreciated. so it could still be possible to inject tenant style through other things than layout hooks. Like javascript injection. Have a good day

Hello! sorry I'm reopening this only because I have the exact same issue with the mobile app Maui Blazor hybrid.

We use Leptonx theme side menu

using Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonXTheme;

and exact same

Configure<AbpLayoutHookOptions>(options =>
        {
            options.Add(
                LayoutHooks.Head.Last,
                typeof(StyleHook)
            );
        });

I tried adding this in App.razor

<LayoutHook Name="@LayoutHooks.Head.Last" Layout="@StandardLayouts.Application" />

Thank you!

Thanks it works! we thought it would work out of the box with leptonx theme side menu

hey do you want me to send you the template again?

or the repro steps are

Add this component

And register it like this in both Server and Wasm projects

Thank you!

I emailed you the whole project source code at liming.ma@volosoft.com 3 days ago

it's also very easy to reproduce.. 2 files to change

Hello, sent thank you.

Both are Blazor ComponentBase components in a Blazor WebApp project and I showed them just to show they work on Body but not on head.

The issue is injection of these components through layout hooks Head.Last They were working with LayoutHooks.Body.First

We are trying to apply white label colors per tenant.

So it looks like this

using MyProject.AdministrationService.Constants;
using MyProject.AdministrationService.Features;
using Microsoft.AspNetCore.Components;
using Volo.Abp.Features;
using Volo.Abp.Settings;

namespace MyProject.Blazor.Shared.Components.Layout;

public partial class AppearanceStyles : ComponentBase
{
    [Inject] private ISettingProvider SettingProvider { get; set; } = null!;

    public string? PrimaryColor { get; private set; }
    public string? SecondaryColor { get; private set; }

    protected override async Task OnInitializedAsync()
    {
        try
        {
            var primaryColor = await SettingProvider.GetOrNullAsync(SettingDefinitionConstants.BrandingPrimaryColor);
            var secondaryColor = await SettingProvider.GetOrNullAsync(SettingDefinitionConstants.BrandingSecondaryColor);

            PrimaryColor = primaryColor ?? SettingDefinitionConstants.BrandingPrimaryColorDefaultValue;
            SecondaryColor = secondaryColor ?? SettingDefinitionConstants.BrandingSecondaryColorDefaultValue;
        }
        catch
        {
            PrimaryColor = null;
            SecondaryColor = null;
        }

        await base.OnInitializedAsync();
    }
}


@using MyProject.AdministrationService.Constants
@using MyProject.AdministrationService.Features
@using Volo.Abp.Features
@using Volo.Abp.Settings

@if (!string.IsNullOrEmpty(PrimaryColor) || !string.IsNullOrEmpty(SecondaryColor))
{
    <style>
        :root {
            --myproject-primary-color: @PrimaryColor;
            --myproject-secondary-color: @SecondaryColor;
        }

        .btn-primary {
            background-color: var(--myproject-primary-color);
            border-color: var(--myproject-primary-color);
        }

        .btn-primary:hover {
            background-color: var(--myproject-primary-color);
            border-color: var(--myproject-primary-color);
            opacity: 0.8;
        }

        .btn-primary:focus {
            background-color: var(--myproject-primary-color);
            border-color: var(--myproject-primary-color);
            box-shadow: 0 0 0 0.25rem rgba(from var(--myproject-primary-color) r g b / 0.25);
        }

        .bg-primary {
            background-color: var(--myproject-primary-color) !important;
        }

        .text-primary {
            color: var(--myproject-primary-color) !important;
        }

        .border-primary {
            border-color: var(--myproject-primary-color) !important;
        }

        .btn-outline-primary {
            border-color: var(--myproject-primary-color);
            color: var(--myproject-primary-color);
        }

        .btn-outline-primary:hover {
            background-color: var(--myproject-primary-color);
            border-color: var(--myproject-primary-color);
            color: #fff;
        }

        .btn-outline-primary:focus {
            background-color: var(--myproject-primary-color);
            border-color: var(--myproject-primary-color);
            color: #fff;
        }

        .nav-pills .nav-link.active, 
        .nav-pills .show > .nav-link {
            background-color: var(--myproject-primary-color);
        }

        .nav-link.active:hover {
            background-color: var(--myproject-primary-color);
            opacity: 0.8;
        }

        /* Secondary Color Styles */
        .btn-secondary {
            background-color: var(--myproject-secondary-color);
            border-color: var(--myproject-secondary-color);
        }

        .btn-secondary:hover {
            background-color: var(--myproject-secondary-color);
            border-color: var(--myproject-secondary-color);
            opacity: 0.8;
        }

        .btn-secondary:focus {
            background-color: var(--myproject-secondary-color);
            border-color: var(--myproject-secondary-color);
            box-shadow: 0 0 0 0.25rem rgba(from var(--myproject-secondary-color) r g b / 0.25);
        }

        .bg-secondary {
            background-color: var(--myproject-secondary-color) !important;
        }

        .text-secondary {
            color: var(--myproject-secondary-color) !important;
        }

        .border-secondary {
            border-color: var(--myproject-secondary-color) !important;
        }

        .btn-outline-secondary {
            border-color: var(--myproject-secondary-color);
            color: var(--myproject-secondary-color);
        }

        .btn-outline-secondary:hover {
            background-color: var(--myproject-secondary-color);
            border-color: var(--myproject-secondary-color);
            color: #fff;
        }

        .btn-outline-secondary:focus {
            background-color: var(--myproject-secondary-color);
            border-color: var(--myproject-secondary-color);
            color: #fff;
        }
    </style>
}

        Configure<AbpLayoutHookOptions>(options =>
        {
            options.Add(
                LayoutHooks.Head.Last,
                typeof(AppearanceStyles)
            );
        });

Also had the same issue in MVC by using

public class BootstrapStyleViewComponent(ISettingProvider settingProvider) : AbpViewComponent
{
    public async Task<IViewComponentResult> InvokeAsync()
    {
        var primaryColor = await settingProvider.GetOrNullAsync(WhileLabelAppSettings.PrimaryColor);
        return View("~/Components/BootstrapStyle/Default.cshtml", primaryColor);
    }
}

And also

Configure<AbpLayoutHookOptions>(options =>
{
    options.Add(
    LayoutHooks.Head.Last,
    typeof(BootstrapStyleViewComponent));
});
Showing 1 to 10 of 27 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
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 18, 2025, 07:10