Daddoon / BlazorMobile

Create full C# driven hybrid-apps for iOS, Android, UWP & Desktop with Blazor!
MIT License
413 stars 55 forks source link

[BUG] JavaScript Error: "undefined" when building the template android project #228

Closed ktaze1 closed 3 years ago

ktaze1 commented 3 years ago

Hey,

I just make a freshly new project and when I tried it run Android project first I had an adb1000: Permission Denied error. So I disable the "Use Fast Deployment" option from Android options in debug settings. (Saw this solution from a stackoverflow answer) First tried in Pixel 2 then Nexus One both with avd with R 11.0 - API 30. There is no build error. Not a single line of code added or deleted.

To be clear, just running dotnet new blazormobile -n MyProjectName suppose to work right? Or do I need to connect this to another xamarin project? I had a tiring day already, I'll look into this with more clear head tomorrow but I highly appreciate if someone who encountered this can point me to right direction

How did I get this error:

    Native Crash Reporting
=================================================================
Got a SEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

No native Android stacktrace (see debuggerd output).

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x8ce2416b):0x8ce2415b  10 e8 
00 00 
00 00 5b 81 c3 93 8e 04 00 8b 75 08  ......[...
....u.
0x8ce2416b  8b 06 85 c0 74 08 89 04 24 e8 07 c7 ff ff 89 34  ....t...$..
....4
0x8ce2417b  24 e8 0a dc ff ff 31 c0 83 c4 10 5e 5b 5d c3 55  $.....1....^[].U
0x8ce2418b  89 e5 53 50 e8 00 00 00 00 5b 81 c3 60 8e 04 00  ..SP.....[..`...
09-14 20:34:19.487 F/libc    (12029): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 12140 (LoadRoots), pid 12029 (yname.MyProject)
09-14 20:34:19.525 E/GeckoConsole(12029): [JavaScript Error: "undefined"]
09-14 20:34:19.807 E/GeckoConsole(12029): [JavaScript Error: "Polling for changes failed: NetworkError when attempting to fetch resource.." {file: "resource://services-settings/remote-settings.js" line: 199}]
09-14 20:34:19.807 E/GeckoConsole(12029): remoteSettingsFunction/remoteSettings.pollChanges@resource://services-settings/remote-settings.js:199:13

On a side note, normally I could see csproj files but double clicking on android project doesn't work. Is this normal or it's some kind of bug?

Daddoon commented 3 years ago

As you stated, the first issue seems to be about Android API 30 changes.

Yes the project should work out of the box from the template, but it's true that i didn't tested anything since API 28 or 29, but as API 30 is now mandatory, maybe something breaked ? Not totally sure, my actual debug builds are still working, but yes i didn't tested on a Device working on API 30.

I don't know what is actually throwing with SIGSEGV in your log, maybe it's the GeckoView component with the new Android API, but it can be some other component in the project, or just simply the Microsoft Debugger not stable on this Android API and VS2019 release, as it can happen, but maybe not.

I think i have to investigate on this. Can you test and confirm that the project work if you try to target some olders OS / API version, like something on API 28 or 29 ?

Thanks !

Daddoon commented 3 years ago

Also, take note that since end of July 2020, Microsoft started supporting Hybrid Blazor apps in their Mobile Blazor Bindings project. Even if it's in preview you may take a look at it, as they are running the Blazor Web app through the same memory area like a Blazor Server app (i imagine) on your device. I imagine there is a lot less overhead to manage, i didn't tested it at the moment. If the thing is working great out of the box, maybe i will start to sunset this project, as it will be less relevant. This was created 2 years ago at a time where Mobile Blazor Bindings was not existing yet, and this kind of functionnality too.

If you go test Mobile Blazor Bindings, Here is the documentation, the announcment was here

ktaze1 commented 3 years ago

Hey, thanks for quick respond!

Upon testing with a API 28, it is indeed working. So thank you!

The reason why choose your project over Mobile Blazor Bindings is that I already have a project made with Blazor WebAssembly but I just need Notifications API on native side and that's all. With Mobile Blazor Bindings, I might need to reconstruct entire project and write a server (?) for it, because as I understand Mobile Blazor Bindings works like Blazor Server rather than a WebAssembly, at least project structure seems like it. I need to look into it more deeply.

Thank you again!

Daddoon commented 3 years ago

What is the problem about the server like model ? I think you can somehow workaround your issue with your initial project, if you move your Blazor UI logic in a Razor Class Library and instead then , having your base project for WASM on one side and the Mobile Blazor Binding referencing the RCL project on one other side.

This way you should I think be able to manage theses kind of scenarios. Don’t have tested it