adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
555 stars 46 forks source link

Unable to hot reload application #153

Closed nathenxbrewer closed 9 months ago

nathenxbrewer commented 10 months ago

When using Rider, I am unable to hot reload the application. I'm using the Reactor.Maui.TemplatePack. These are the steps I am taking to attempt to hot reload:

  1. Run app in Debug from Rider
  2. Run dotnet-maui-reactor -f net7.0-android from terminal

I get the following error:

Detected changes to 'Pages/MainPage.cs' Replacing syntax tree for: Pages/MainPage.cs Connecting to Hot-Reload server (Port: 45820)...connected. Unable to hot reload the application: System.Net.Sockets.SocketException (0x80004005): Undefined error: 0 at MauiReactor.HotReloadConsole.HotReloadClient.SendAssemblyFileToServer(MemoryStream stream, MemoryStream pdbStream, CancellationToken cancellationToken) in C:\projects\reactorui-maui\src\MauiReactor.HotReloadConsole\HotReloadClient.cs:line 334 at MauiReactor.HotReloadConsole.HotReloadClient.ConnectionLoop(CancellationToken cancellationToken) in C:\projects\reactorui-maui\src\MauiReactor.HotReloadConsole\HotReloadClient.cs:line 156 Detected changes to 'Pages/MainPage.cs' Replacing syntax tree for: Pages/MainPage.cs

adospace commented 10 months ago

Hi, I don't think it is a problem related to Rider (even if Visual Studio automatically installs its version of the Android emulator). Looking at the exception, it seems that it's unable to connect to the emulator. dotnet-maui-reactor uses adb (https://developer.android.com/tools/adb)

can you verify that: 1) adb is configured correctly, i.e. you can run adb commands without problems 2) you're running the app in debug mode 3) have only one emulator running

just to know, do you have Visual Studio installed? Are you able to correctly run/debug MAUI applications from both Rider/VS?

nathenxbrewer commented 10 months ago

I have adb installed properly on my Mac. I use adb daily to connect to my physical android devices to test MAUI apps for my organization. I tried using mauireactor hot reload with both my physical device and my emulator and both give the same error.

nathenxbrewer commented 10 months ago

I also tried within Parallels desktop using Windows with Visual Studio 2022 connected to an emulator and that also gave the same error.

nathenxbrewer commented 10 months ago

I was able to get rid of the error on Mac by forgetting the Wi-Fi network on my phone and reconnecting adb. However, I still cannot get hot reload to work. Terminal shows no errors but it just simply does not update the UI. Attached is a screen recording.

https://github.com/adospace/reactorui-maui/assets/43285863/d0853cbe-34c3-4823-b9fb-d514f17f6ea7

adospace commented 10 months ago

hum, it's strange, this is my screen:

JetBrains Rider - MauiReactorTestApp – MainPage.cs - 15 September 2023 - Watch Video

a couple of things: 1) It seems like the new assembly is sent to another app running, maybe you have another app using MauiReactor that is running at the same time in the emulator, or in another emulator/device? 2) You're using .net 8 preview, which should not be a problem for MauiReactor hot reload, but I haven't tested it with .net 8 so far.

nathenxbrewer commented 9 months ago

I only have 1 instance of Rider open and one adb device connected. I have tried this after a fresh boot with no other projects open or devices connected.

I completely removed .NET 8 SDK and Runtime from my machine, did not make a difference. App still is unchanged.

AswinPG commented 9 months ago

I am also facing this issue, there are no errors. It shows successful reload but the UI is not refreshed. This only happens if I use the Appshell template. In the normal template the reload is working fine

adospace commented 9 months ago

oh, ok, I see now, the problem seems related to the AppShell template, investigating...