maui icon indicating copy to clipboard operation
maui copied to clipboard

Returning UIImage in custom ImageSourceService doesn't trigger an UI update

Open roubachof opened this issue 1 year ago • 7 comments

Description

Hi there !

https://github.com/roubachof/Maui.Nuke has a weird issue when returning a valid UIImage with ImageSourceServiceResult. It doesn't seem to trigger the display of the image right away... But if you force the layout to refresh, the UIImage renders correctly.

I'm plugging into Image service architecture in order to use ImageCaching.Nuke nuget (which is a swift binding).

public static class ImageSourcesMauiAppBuilderExtensions
{
    public static MauiAppBuilder UseNuke(this MauiAppBuilder builder, bool showDebugLogs = false)
	{
#if __IOS__
		NukeController.ShowDebugLogs = showDebugLogs;
		builder.ConfigureImageSources(services =>
		{
			services.AddService(
				svcs => new NukeFileImageSourceService(
					svcs.GetService<ILogger<FileImageSourceService>>()));

			services.AddService(
				svcs => new NukeUriImageSourceService(
					svcs.GetService<ILogger<UriImageSourceService>>()));

			services.AddService<FileImageSource>(
				svcs => new NukeFileImageSourceService(
					svcs.GetService<ILogger<FileImageSourceService>>()));

			services.AddService<UriImageSource>(
				svcs => new NukeUriImageSourceService(
					svcs.GetService<ILogger<UriImageSourceService>>()));
		});
#endif
		return builder;
	}
}

Steps to Reproduce

  1. Create new MAUI app with the default template
  2. Clone https://github.com/roubachof/Maui.Nuke next to your app
  3. Reference Maui.Nuke csproj in your app
  4. Initialize Nuke as described in Maui.Nuke
  5. put a breakpoint in https://github.com/roubachof/Maui.Nuke/blob/d8682d833abd7cd6bafb2e82e46e5e72d3823b47/Maui.Nuke/NukeFileImageSourceService.cs#L105
  6. You will see UIImage is not null and valid, but you won't see the bot displayed
  7. If you click the button, image appears

Link to public reproduction project repository

https://github.com/roubachof/Maui.Nuke

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS

Did you find any workaround?

nope

Relevant log output

nothing here

roubachof avatar Feb 21 '23 19:02 roubachof

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Feb 22 '23 19:02 ghost

I'm facing this issue as well on iOS.

@PureWeen do you know if this can be fixed by using a custom handler in .NET MAUI somehow? 🤔

Thanks in advance

vhugogarcia avatar May 03 '23 19:05 vhugogarcia

Maybe this can improve performance a lot for Maui in iOS when rendering images lots os images in a collection view or bindable layout. @jonathanpeppers what do you think? Maybe integrate it natively on MAUI?

Thank you

vhugogarcia avatar May 04 '23 22:05 vhugogarcia

Verified this issue with VSM 17.6.7 (build 417). Can repro on ios platform.

homeyf avatar Nov 29 '23 08:11 homeyf

Just tested with .net8 MAUI, and still failing

roubachof avatar Jan 08 '24 15:01 roubachof

https://github.com/roubachof/Maui.Nuke

Hello @roubachof , I'm wondering if you had opportunity to review my comment here on how I solved the issue for my project: https://github.com/roubachof/Maui.Nuke/issues/2#issuecomment-1555198169 in .NET 7+

I'm not sure if that will solve the issue 100% but just wanted to share my grain of salt 😃 .

Regards

vhugogarcia avatar Jan 08 '24 17:01 vhugogarcia

I tested it with .net 7 and .net 8, same issue

roubachof avatar Jan 08 '24 17:01 roubachof