Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images are not displayed in release with AndroidEnableMarshalMethods=true #9810

Open
alex3696 opened this issue Feb 17, 2025 · 3 comments
Open
Assignees
Labels
Area: Marshal Methods Issues that only occur when enabling Marshal Methods.

Comments

@alex3696
Copy link

alex3696 commented Feb 17, 2025

Description

I am not understanding what caused such behavior: marshaling or together with trimming or AOT. But Images are not displayed in release on android with AndroidEnableMarshalMethods is true.

<AndroidEnableMarshalMethods>true</AndroidEnableMarshalMethods>

public class ImgResExtension : IMarkupExtension
{
    public string? Source { get; set; }
    public object? ProvideValue(IServiceProvider serviceProvider)
    {
        if (Source == null)
            return null;
        var path = $"Maui9MarshalAndImageBug.Resources.Images.{Source}";
        //return ImageSource.FromResource(path);
        var assembly = Assembly.GetAssembly(typeof(App));
        if (assembly is null)
            return null;
        var stream = assembly.GetManifestResourceStream(path);
        if (stream is null)
            return null;
        return ImageSource.FromStream(() => stream);
    }
}
  <Image Source="{gui:ImgResExtension dotnet_bot.png}"
          HeightRequest="185"
          Aspect="AspectFit"/>

Steps to Reproduce

see the repository

Link to public reproduction project repository

[email protected]:alex3696/Maui9MarshalAndImageBug.git
https://github.com/alex3696/Maui9MarshalAndImageBug.git

Version with bug

9.0.40 - no image
9.0.30 - app crash

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

Android

Affected platform versions

tested on Andriod9 device and virtual Andriod14

Did you find any workaround?

No response

Relevant log output

@alex3696 alex3696 added the t/bug label Feb 17, 2025
@Zhanglirong-Winnie
Copy link

Zhanglirong-Winnie commented Feb 18, 2025

This issue has been verified Visual Studio 17.14 Preview 1(9.0.40 ). Can repro this issue on Android platform. On 9.0.30 App will crash.
Image

@alex3696
Copy link
Author

You are right, on 9.0.30 app crashing

@rmarinho rmarinho transferred this issue from dotnet/maui Feb 19, 2025
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Feb 19, 2025
@jpobst
Copy link
Contributor

jpobst commented Feb 19, 2025

This seems to be the reason that the image is not showing up:

02-19 08:30:42.570 27351 27351 W Glide   : Load failed for [mono.android.runtime.InputStreamAdapter@3a55284] with dimensions [923x486]
02-19 08:30:42.570 27351 27351 W Glide   : class com.bumptech.glide.load.engine.GlideException: Failed to load resource
02-19 08:30:42.570 27351 27351 W Glide   :   Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{InputStreamAdapter->Object->Drawable}, LOCAL
02-19 08:30:42.570 27351 27351 W Glide   :     Cause (1 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{InputStreamAdapter->Drawable->Drawable}
02-19 08:30:42.570 27351 27351 W Glide   :     Cause (2 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{InputStreamAdapter->GifDrawable->Drawable}
02-19 08:30:42.570 27351 27351 W Glide   :     Cause (3 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{InputStreamAdapter->Bitmap->BitmapDrawable}
02-19 08:30:42.570 27351 27351 W Glide   :     Cause (4 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{InputStreamAdapter->BitmapDrawable->Drawable}
02-19 08:30:42.578 27351 27351 W Glide   : Load failed for [crc6488302ad6e9e4df1a.ImageLoaderCallback@8d46097] with dimensions [923x486]
02-19 08:30:42.578 27351 27351 W Glide   : class com.bumptech.glide.load.engine.GlideException: Failed to load resource

It only happens in Release with <AndroidEnableMarshalMethods>true</AndroidEnableMarshalMethods>.

@jpobst jpobst added Area: Marshal Methods Issues that only occur when enabling Marshal Methods. and removed needs-triage Issues that need to be assigned. t/bug labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Marshal Methods Issues that only occur when enabling Marshal Methods.
Projects
None yet
Development

No branches or pull requests

4 participants