Skip to content

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

Open
@alex3696

Description

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

Activity

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

Metadata

Assignees

Labels

Area: Marshal MethodsIssues that only occur when enabling Marshal Methods.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions