maui icon indicating copy to clipboard operation
maui copied to clipboard

Error boundary message does not display on mobile devices

Open ltemimi opened this issue 2 years ago • 6 comments

Description

I have a MAUI Blazor project that uses the Error Boundary component . The error message displays correctly in Blazor server but not on mobile devices

image

Steps to Reproduce

1 Creat new dotnet Maui Bl;azor app 2 - Place an error boundary around the body tag

           <ErrorBoundary @ref="_errorBoundary">
               <ChildContent>
                  @Body
               </ChildContent>
               <ErrorContent Context="exception">
                   <ErrorBoundaryMessage
                       ErrorBoundary="@_errorBoundary"
                       Exception="exception">
                   </ErrorBoundaryMessage>
               </ErrorContent>
           </ErrorBoundary>
       </article>

3 - Simulate an error and observe it renders correctly on Blazor server but not on IOS or Androind

Version with bug

6.0.408 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

Windows server 2022

Did you find any workaround?

No

Relevant log output

just nothing is displayed on ios and android

ltemimi avatar Aug 03 '22 17:08 ltemimi

Hi @ltemimi, would you please provide a public, minimal repro project hosted as a GitHub repository that demonstrates the problem? Thanks!

MackinnonBuck avatar Aug 04 '22 16:08 MackinnonBuck

Hi @ltemimi. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Aug 04 '22 16:08 ghost

Another thing you could try is checking if the default error boundary works correctly.

MackinnonBuck avatar Aug 04 '22 16:08 MackinnonBuck

The default ErrorBoundary seems to work fine in a .NET MAUI Blazor app:

image

danroth27 avatar Aug 04 '22 16:08 danroth27

Hi Many thanks for your help 1 - I am attaching the code to show the issue , the code has three projects a BlazorBase (bootstrapper) that is referenced by a Blazor Server project and a Dot net Maui blazor project. It can be used to show that that the error boundary works on blazor server but not in mobile devices.

To get the code bigger than 25 mb please use the link: https://1drv.ms/u/s!Ai1jsiYR5baCmpReUmQua3v6AztSpw?e=o1ZnJR

Code Android IOS BlazorServer

ltemimi avatar Aug 08 '22 15:08 ltemimi

Are we saying I am stuck with the issue? Any suggestion work around?

ltemimi avatar Aug 10 '22 09:08 ltemimi

Hi @ltemimi. The reason your ErrorBoundaryMessage is failing when running in .NET MAUI is because it has a dependency on the IHostingEnvironment service, which is only available when running in the context of an ASP.NET Core app. You can see this is the issue by checking dev tools console for the browser control (you can bring up the dev tools when running on Windows by hitting F12):

image

You'll need to refactor your ErrorBoundaryMessage component to not depend on this interface.

danroth27 avatar Aug 10 '22 23:08 danroth27