Skip to content

UriImageSource caching not implemented for Windows & check TODO comments around caching in general #9138

Description

@GeorgeLeithead

Description

Looking at the UriImageSource control, in the GetStreamAsync method it states the following which gives the impression that caching is not implemented. I believe that in Xamarin.Forms caching was done directly in ImageSource but in MAUI I believe it's done in UriImageSourceService for the platforms?

Should this be cleaned up as appropriate?

		async Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken = default(CancellationToken))
		{
			cancellationToken.ThrowIfCancellationRequested();

			Stream stream = null;

			if (CachingEnabled)
			{
				// TODO: CACHING https://github.com/dotnet/runtime/issues/52332

				// var key = GetKey();
				// var cached = TryGetFromCache(key, out stream)
				if (stream is null)
					stream = await DownloadStreamAsync(uri, cancellationToken).ConfigureAwait(false);
				// if (!cached)
				//    Cache(key, stream)
			}
			else
			{
				stream = await DownloadStreamAsync(uri, cancellationToken).ConfigureAwait(false);
			}

			return stream;
		}

Steps to Reproduce

View the source of UriImageSource.cs

Version with bug

6.0.408 (current)

Last version that worked well

Unknown/Other

Affected platforms

I was not able test on other platforms

Affected platform versions

NA

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions