maui icon indicating copy to clipboard operation
maui copied to clipboard

Crash on scrolling collection view

Open cucumber-sp opened this issue 3 years ago • 3 comments
trafficstars

Description

After loading content and scroll down in content view, app crashes with some java canvas error. Works fine on windows

Steps to Reproduce

Download project, make build for android (or launch with debug on local device), click load videos button, wait, scroll down

Link to public reproduction project repository

https://github.com/cucumber-sp/YPlayer

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11, 12 (MIUI 12, 13)

Did you find any workaround?

No response

Relevant log output

Java.Lang.RuntimeException
  Message = Canvas: trying to use a recycled bitmap android.graphics.Bitmap@c8f384a

cucumber-sp avatar Nov 06 '22 11:11 cucumber-sp

Seems similar or duplicate from https://github.com/dotnet/maui/issues/9712

jsuarezruiz avatar Nov 07 '22 15:11 jsuarezruiz

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 Nov 07 '22 15:11 ghost

Any fix for this, xD I'm going to have to migrate the project to Xamarin.

Phantom-KNA avatar Nov 11 '22 07:11 Phantom-KNA

I spent a few hours to analyze this problem.

This bug was created following this pull request: https://github.com/dotnet/maui/pull/7348

While waiting for Microsoft to permanently fix this bug, the workaround consists of redoing the clear before each source image change.

Below is an example of code to add the clear in the source image mapping.

using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;

namespace MauiCanvas;

public static class MauiProgram
{
	public static MauiApp CreateMauiApp()
	{
		var builder = MauiApp.CreateBuilder();
		builder
			.UseMauiApp<App>()
			.ConfigureFonts(fonts =>
			{
				fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
				fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
			});

#if __ANDROID__
        ImageHandler.Mapper.PrependToMapping(nameof(Microsoft.Maui.IImage.Source), (handler, view) => PrependToMappingImageSource(handler, view));
#endif

        return builder.Build();
	}

#if __ANDROID__
    public static void PrependToMappingImageSource(IImageHandler handler, Microsoft.Maui.IImage image)
    {
        handler.PlatformView?.Clear();
    }
#endif

}

mohachouch avatar Dec 01 '22 08:12 mohachouch