Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The **XAML Hot Reload** feature does not work when debugging on Android devices. #1241

Closed
Calichi opened this issue Jun 25, 2024 · 24 comments
Closed
Assignees
Labels
area-hotreload Issues with Hot Reload experiences area-maui triaged The issue has been triaged vs-sync Add this label to synchronize the issue to AzDo vs-syncd Linked to AzDO

Comments

@Calichi
Copy link

Calichi commented Jun 25, 2024

Type: Bug

The changes are not applied after editing and saving a XAML file, even when pressing the "Fire" button. The .NET Hot Reload output displays No changes were found.

Extension version: 1.0.6
VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:34:26.404Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz (4 x 2592)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 7.84GB (1.94GB free)
Process Argv --crash-reporter-id 19165560-5fd2-482a-994e-35e72cd32781
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:31067544
chatpanelc:31048052
dsvsc021:30996838
f3je6385:31013174
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupyter:31046869
newcmakeconfigv2:31071590
impr_priority:31082723

| VS Bug 2113764

@AbhitejJohn AbhitejJohn added the area-hotreload Issues with Hot Reload experiences label Jun 25, 2024
@BretJohnson
Copy link
Member

@Calichi - FYI, XAML Hot Reload should work as you type. Saving the file shouldn't be necessary. And the "No changes were found" message actually refers to C# changes, not XAML changes, though we're working on improving that message to make it more explicit. FYI on all that.

As for the core issue here, can you provide more info. If you create a new, simple MAUI project (bring up the command palette / .NET: New Project... / .NET MAUI) does Hot Reload work there? Does it fail for all pages in your app or just some? When it fails, can you please share the contents of the .NET Hot Reload output pane and the Debug Console app output, especially searching for Hot Reload related errors (look for Hot Reload) in the app output.

Thanks. I would like to get this issue tracked down & working, both for you and for others who may run into the same problem, whatever it is.

@BretJohnson BretJohnson self-assigned this Jul 1, 2024
@Calichi
Copy link
Author

Calichi commented Jul 2, 2024

@BretJohnson - I am attaching a video divided into two parts of the entire process. The overlay of the mobile device screen is not synchronized with the video, but it was recorded during the demonstration.

bug_hot_reload_part_1.mp4
bug_hot_reload_part_2.mp4

@Calichi
Copy link
Author

Calichi commented Jul 2, 2024

@BretJohnson - Note also, there is an instruction: ‘Start sdb and execute…’ What is sdb? Could there have been a typo when trying to write adb, or is it some tool that I am unfamiliar with? I have already conducted a search, but I cannot find anything related to it

@BretJohnson
Copy link
Member

@BretJohnson - Note also, there is an instruction: ‘Start sdb and execute…’ What is sdb? Could there have been a typo when trying to write adb, or is it some tool that I am unfamiliar with? I have already conducted a search, but I cannot find anything related to it

Where do you see that message? Can you paste the full message or a screenshot maybe?
And thank you for the videos - they are indeed helpful.

@Calichi
Copy link
Author

Calichi commented Jul 2, 2024

@BretJohnson - The message is located in the yellow-highlighted area, but it is in Spanish.
Bug_start_sdb

@BretJohnson
Copy link
Member

@BretJohnson - The message is located in the yellow-highlighted area, but it is in Spanish. Bug_start_sdb

Ah, gotcha. Below is the English version of that UI. sdb isn't a typo, it refers to Android debugger technology. Though as I read that message it does seem confusing, it kind of reads like an instruction to the user on something they should do rather than an explanation of what the build/launch process is doing automatically to connect the debugger. I'll create a bug on that, suggesting the message improved. Thanks for pointing it out.

image

@BretJohnson
Copy link
Member

But as for your issue, the Hot Reload initialization error: No HotReload connection specified message in the app launch output indicates a problem. XAML Hot Reload won't work if that message shows up. Now to figure out why - what's going wrong that triggers that.

Can you please try this:

  1. cd "C:\Program Files (x86)\Android\android-sdk\platform-tools" (assuming your android sdk is installed there, which it normally is)
  2. See what the output of .\adb.exe shell ls -l /data/local/tmp is. There should be an ide-launchenv.txt file in that directory, which is how environment variables, like the one used for the HotReload connect info, get passed to the Android app at launch time. If something went wrong creating that file - perhaps a permission issue with the Android device/emulator in question - that would cause the symptoms you see.

@BretJohnson
Copy link
Member

And what kind of Android device is this? It's a physical Android device, not an emulator, right?
Can you try with an emulator image, like say a Pixel 7 emulator, and see if that works.
My guess is that there's some security issue (or possibly a non security device specific issue) that causes using adb to create the /data/local/tmp/ide-launch-env.txt file to fail on that device. If that's the case, I'd like us to handle that scenario better, though I'm not sure how yet. In any case, let's see what you find with the above checks & go from there. Thanks for your help tracking this down.

image

@Calichi
Copy link
Author

Calichi commented Jul 2, 2024

@BretJohnson - Indeed, I am using a physical mobile device to debug my applications, and I have no intention of doing so on an emulator. For the same reason, I am seeking assistance. Perhaps you could explain how executing on the emulator could help resolve the issue with the physical device? Or what is their relationship?

It’s worth mentioning that I have debugged on the Windows target, and Hot Reload works perfectly.

Perhaps it’s not relevant, but I usually work with Visual Studio Community, and everything works perfectly there. I wanted to bring my project to VS Code because I heard that it now supports Hot Reload on Android devices, and honestly, it’s more convenient for me to work in VS Code.

Finally, I am fully willing to provide any information you need to help resolve this issue.

@Calichi
Copy link
Author

Calichi commented Jul 2, 2024

@BretJohnson - This is the result of executing the mentioned command, but on the physical device, not on an emulator. As you can see, the mentioned file appears ide-launch-env.txt. However, it differs slightly in the name. Could this be the cause of the issue?

Captura de pantalla 2024-07-02 180438

@BretJohnson
Copy link
Member

@Calichi - Thanks for that info. Can you also share the results of running this adb command (with the physical device connected): .\adb.exe shell cat /data/local/tmp/ide-launchenv.txt
And the file name looks correct for you - it should indeed be ide-launchenv.txt. The issue must be something else.

As for running on an emulator, I only mentioned that to better understand what scenarios do & don't work for you, as a troubleshooting step. But you don't need to do it - the adb output above is the most useful. And indeed my goal, as is yours, is figure out why this isn't working for you, with your device, and fix things so it does (probably by making some change in our code, though maybe there's a workaround in advance of that).

Thanks again for your help tracking this down. We're getting closer.

@Calichi
Copy link
Author

Calichi commented Jul 3, 2024

@BretJohnson

Here's requested execution's result for the given command:


Captura de pantalla 2024-07-02 212011

@BretJohnson
Copy link
Member

@Calichi Thanks. That looks valid. As the next check do you think you can add a little code to your app to get the value of the RuntimeInformation.OSDescription property, running that on your Android device (like in the debugger) and see what it returns. The current code checks if RuntimeInformation.OSDescription.Contains("android") in order to determine if it's an Android device - if that check returned false for some reason, it would result in the behavior you see. That check may not be exactly right, for all devices, and need to be updated - but we'll see, based on what your device reports. Thanks again.

@BretJohnson BretJohnson added the vs-sync Add this label to synchronize the issue to AzDo label Jul 3, 2024
@AllenD-MSFT AllenD-MSFT added the vs-syncd Linked to AzDO label Jul 3, 2024
@Calichi
Copy link
Author

Calichi commented Jul 3, 2024

@BretJohnson

Here's the result.

Captura de pantalla 2024-07-02 215019

@Calichi
Copy link
Author

Calichi commented Jul 3, 2024

@BretJohnson

More information.

Captura de pantalla 2024-07-02 221051

@BretJohnson
Copy link
Member

Thanks. So that's the issue. And this device is an OPPO A15 (https://www.oppo.com/en/smartphones/series-a/a15/specs/), right? It looks like the OS there is ColorOS 7.2 based on Android 10, so Android with some customizations. In any case, I'll look to update the code for a better check on whether running on Android, avoiding RuntimeInformation.OSDescription. In the meantime, I can't think of any good workarounds, other than say using an emulator temporarily for Hot Reload. But I'll fix it. We publish weekly pre-release channel updates of the extension. Once the bug here is noted as fix, look for an update published to pre-release there that contains the fix. So you shouldn't have to wait too long. Thanks again very much for your help tracking this down.

@Calichi
Copy link
Author

Calichi commented Jul 3, 2024

@BretJohnson

You’re welcome! Thank you for your attention and follow-up. I’ll wait for the update

@Calichi Calichi closed this as completed Jul 3, 2024
@BretJohnson
Copy link
Member

I'll update this issue to mark it fixed, once we have a fix in place & we'll close the issue after the fix is released publicly.

@BretJohnson BretJohnson reopened this Jul 3, 2024
@Calichi
Copy link
Author

Calichi commented Jul 3, 2024

@BretJohnson

Ok.

I can post another bug about debugging MAUI apps on my Android device, but this one occurs in both VS Code and VS Community.

@BretJohnson
Copy link
Member

@BretJohnson

Ok.

I can post another bug about debugging MAUI apps on my Android device, but this one occurs in both VS Code and VS Community.

Sounds good. For issues that happen in both VS Windows and VS Code, I'd suggest reproducing it in VS Windows, then create a feedback ticket (Help / Send Feedback / Report a Problem). Feedback tickets include logs which sometimes help. And note on the feedback ticket that you also see it on VS Code. Reporting a separate VS Code bug here, in addition to the VS Windows feedback ticket, shouldn't normally be necessary, but on the other hand it couldn't hurt and will raise visibility so feel free to do that if you'd prefer.

@Calichi
Copy link
Author

Calichi commented Jul 3, 2024

Once again, thank you very much!

@emaf emaf added the triaged The issue has been triaged label Jul 15, 2024
@ziomek64
Copy link

For me XAML hot reload works in emulator but doesn't in real device too

@BretJohnson
Copy link
Member

This is fixed, in C# extension version 2.39 (and later), currently published to the pre-release channel.
@Calichi - After updating to the latest prerelease version of the C# extension, if you still see any problems let us know.
@ziomek64 - Same for you. Thanks.

@Calichi
Copy link
Author

Calichi commented Aug 9, 2024

@BretJohnson

This issue seems to be resolved because I’ve been able to debug on the device. However, hot reload doesn’t load on various occasions during the start of debugging, and it shows me these messages:

Hot Reload initialization error: Launch environment file was last updated 141 seconds ago and is expired
Hot Reload initialization error: No HotReload connection specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-hotreload Issues with Hot Reload experiences area-maui triaged The issue has been triaged vs-sync Add this label to synchronize the issue to AzDo vs-syncd Linked to AzDO
Projects
None yet
Development

No branches or pull requests

7 participants