dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.2k stars 174 forks source link

Black screen instead of exception page #228

Closed Dreamescaper closed 3 years ago

Dreamescaper commented 3 years ago

In most cases for me when exception happens I simple see fully black screen. I see some text when try to scroll the page, but that doesn't help. That makes debugging hell of a lot harder, considering that exceptions are not logged anywhere else!

I'm trying to find concise repro case for this behavior.

Details ![Mryhbqn1HZ](https://user-images.githubusercontent.com/17177729/98969555-9fc69800-2517-11eb-8e55-dc824d10a0ba.gif)
Eilon commented 3 years ago

Oh I wonder if this is related to dark/light mode? That's probably a bug in the default error screen.

Or, it kind of looks like you've entered The Matrix! (But with blue text instead of green.)

Dreamescaper commented 3 years ago

No, not related to dark/light mode. Under some conditions it's ok, sometimes like that with same device settings.

Eilon commented 3 years ago

Hmm that's quite odd then. I think for that screen it might not set all the foreground/background colors and if you're in dark/light mode that can create bad combinations (e.g. black on black). That's usually the problem when I see such problems.

Eilon commented 3 years ago

This is the error UI:

https://github.com/xamarin/MobileBlazorBindings/blob/master/src/Microsoft.MobileBlazorBindings/ErrorPageHelper.cs#L24-L55

Looking at it now, I don't see any colors set at all, so this is certainly odd. But maybe setting explicit colors is best to avoid any risk of inheriting some bad color combinations from something.

Dreamescaper commented 3 years ago

Sometimes I get the opposite - simple white screen, nothing else.

Eilon commented 3 years ago

I'm guessing it's doing black on black and white on white. I think setting explicit colors is the right approach.

Eilon commented 3 years ago

It would be nice to be theme-aware using a little helper like this:

https://github.com/Eilon/Rezipe/blob/master/src/Rezipe/RezipeBaseComponent.cs#L29-L32

Dreamescaper commented 3 years ago

OK, I see that I get simple white screen when my Shell fails to create, and I had no such line in my App: MainPage = new ContentPage();

(didn't think that it mattered).

But adding this line fixed this particular issue - not the black screen though, so I keep digging.

Eilon commented 3 years ago

Ah yes you need to set some initial value for MainPage because all the Blazor stuff loads async. So you could have just an empty ContentPage or you could even put a splash screen there. The Blazor stuff loads very quickly (depending on the app) so there's usually not much to do aside from setting some default value.

Dreamescaper commented 3 years ago

Yeah, I was just surprised that that line would affect error screen. I mean, everything else works fine for me without that line.

Eilon commented 3 years ago

Yeah that's certainly bizarre.

Dreamescaper commented 3 years ago

Ok, so I get this black screen when I attempt to render EditForm component (the one for Web :) ). It obviously wasn't able to render that (fails with KeyNotFoundException), and attempts to show Error page. I don't know why it fails to display it though.

I have seen such behavior under other conditions, but can't recall anything right now.

Dreamescaper commented 3 years ago

However I checked that it does help to BackgroundColor to white explicitly.

Eilon commented 3 years ago

Thank you for sending the PR, it is now merged!