maui
maui copied to clipboard
Crash on scrolling collection view
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
Seems similar or duplicate from https://github.com/dotnet/maui/issues/9712
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.
Any fix for this, xD I'm going to have to migrate the project to Xamarin.
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
}