dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.17k stars 1.74k forks source link

Empty NavigationPageRenderer crashes the app #21116

Open BlueRaja opened 7 months ago

BlueRaja commented 7 months ago

Description

Simply using an empty NavigationPageRenderer will crash the app

Steps to Reproduce

public class MyNavigationPageRenderer : NavigationPageRenderer
{
    public MyNavigationPageRenderer(Context context) : base(context) {}
}
var builder = MauiApp.CreateBuilder();
builder
    .UseMauiApp<App>()
    .UseMauiCompatibility()
    .ConfigureMauiHandlers((handlers) => handlers.AddCompatibilityRenderer(typeof(NavigationPage), typeof(MyNavigationPageRenderer)));

Expected results: App starts

Actual results:

System.MissingMethodException: 'Method not found: int .Layout.get_toolbar()'

in Android.Runtime.RuntimeNativeMethods.monodroid_debugger_unhandled_exception in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:13,5 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:368,26 in Microsoft.Maui.Controls.Compatibility.Platform.Android.AppCompat.NavigationPageRenderer.SetupToolbar in Microsoft.Maui.Controls.Compatibility.Platform.Android.AppCompat.NavigationPageRenderer.OnElementChanged in Microsoft.Maui.Controls.Compatibility.Platform.Android.VisualElementRenderer.SetElement in Microsoft.Maui.Controls.Compatibility.Platform.Android.VisualElementRenderer.Microsoft.Maui.Controls.Compatibility.Platform.Android.IVisualElementRenderer.SetElement in Microsoft.Maui.Controls.Compatibility.RendererToHandlerShim.SetVirtualView in Microsoft.Maui.Handlers.ViewHandler<Microsoft.Maui.IView,Android.Views.View>.SetVirtualView at D:\a_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:56,4 ...

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Nope. I'm still trying to figure out how to implement the equivalent functionality using handlers.

Relevant log output

No response

think-mcunanan commented 7 months ago

Has anyone figure this out? I'm having the same problem.

BlueRaja commented 7 months ago

Uh, no. A repro was provided. The "needs repro" tag is incorrect.

MAICO-Diagnostics commented 4 months ago

Please, please, have a look at this. We are stuck with our XF->MAUI migration :-(

AndriyGlodan commented 2 weeks ago

Will there be any reaction from the developers? Do you follow the same rule as it was with Xamarin: "If we can't fix something, we keep quiet about it"????

pictos commented 2 weeks ago

look like the repro was deleted

BlueRaja commented 2 weeks ago

look like the repro was deleted

It was not. It's under "steps to reproduce".

It's also trivial to reproduce just from the description, because it's an entire, major feature that literally does not work at all. This bug report is not "there is an edge case that does not work", it's "this feature never works, even in the simplest, most trivial case."

pictos commented 2 weeks ago

@BlueRaja repro, is a runnable project that reproduces the issue. Friendly asking... If it's trivial why not provide it and help us to help you?

BTW, I'm a community contributor and don't work for maui team