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

Device freezes and not able to hit breakpoints when disconnecting USB and reattaching it while debugging. #21310

Open
haavamoa opened this issue Sep 26, 2024 · 11 comments
Labels
need-info Waiting for more information before the bug can be investigated
Milestone

Comments

@haavamoa
Copy link

haavamoa commented Sep 26, 2024

Apple platform

iOS

Framework version

net8.0-*

Affected platform version

.NET 8.0.100

Description

I upgraded to Xcode 16 last week, but after reading this post I removed it and installed Xcode 15.4. After doing so, I started noticing that debugging my app with a device sometimes freezes the app and I loose breakpoints.

Setup:

  • 2x devices, iOS 17.5.1 and iOS 18.0. Same issue for both.
  • Using Intellij Rider and VS Code + Meteor. Same issue for both.
  • Debugging using USB.

It seems like this is a known issue from Xcode 16 release notes

I want to create this issue so others can comment on their workarounds if others are experiencing the same behaviour as me.

Steps to Reproduce

  1. Connect a iPhone to your Mac.
  2. Debug a MAUI app, make sure you can set breakpoints and they are hit.
  3. Disconnect the USB
  4. Connect the USB
  5. Start debugging after it was connected.
  6. Notice that breakpoints is not hit and the app randomly freezes for a couple of minutes.

Did you find any workaround?

  • It seems like rebooting my device stops the issue, but once I disconnect the USB and reattach it, the bug seem to come back.

  • It seems like this is a known issue from Xcode 16 release notes, and the workaround mentioned by Apple seems to work for me.

Relevant log output

No response

@rolfbjarne
Copy link
Member

This is interesting, and I don't really have any ideas what might be causing it, except the Xcode issue you linked to.

  • Did your colleague who can also reproduce this ever install Xcode 16?

  • Can you try adding this to your csproj to see if it makes a difference (this might only work with VS, not VSCode, nor any other IDEs):

    <PropertyGroup>
        <IOSDebuggerConnectOverUsb>false</IOSDebuggerConnectOverUsb>
    	<IOSDebugOverWiFi>true</IOSDebugOverWiFi>
    </PropertyGroup>

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Sep 26, 2024
@rolfbjarne rolfbjarne added this to the Future milestone Sep 26, 2024
@haavamoa
Copy link
Author

haavamoa commented Sep 26, 2024

  • Did your colleague who can also reproduce this ever install Xcode 16?

Yes.

  • Can you try adding this to your csproj to see if it makes a difference (this might only work with VS, not VSCode, nor any other IDEs):
    <PropertyGroup>
        <IOSDebuggerConnectOverUsb>false</IOSDebuggerConnectOverUsb>
    	<IOSDebugOverWiFi>true</IOSDebugOverWiFi>
    </PropertyGroup>
    

I tried it running Intellij Rider, there is no difference. I don't have VS 4 Mac as it's not supported anymore, and I do not have a Windows machine to test VS 4 Windows.


Unfortunately, it now happened again and I tried following my own workarounds, none of them works :(

In this scenario, I lost breakpoints from a USB disconnect. I tried to turn off Wifi on Mac and Airplane mode on device. I disconnected the USB and reattached it. Cleaned my bin folders, and started debugging. No breakpoints is hitting.
I tried rebooting the device, cleaned my bin folders and started debugging. No breakpoints is hit.

there's no particular reason why I clean my bin folders, its just my paranoia kicking in :D

I closed the app, and Intellij Rider still thinks my app is running, with breakpoints disabled:
image

:( So now I am completely stuck debugging my iOS app.

This is the project I am running, specifically the Components app project.

@rolfbjarne
Copy link
Member

Do you see the same behavior if you create a new project?

@rolfbjarne rolfbjarne closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
@rolfbjarne rolfbjarne reopened this Sep 26, 2024
@haavamoa
Copy link
Author

I can try a brand new project, but I see the same behaviour for all of my three app project I work on in my day job. I'll test a new one now.

@haavamoa
Copy link
Author

Just created a new project, no breakpoints are hit :(
image

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Sep 26, 2024
@haavamoa
Copy link
Author

Tried my workaround for the new project when this bug appeared:

I just turned off Wifi + enabled Airplane mode, then redeployed, it now hits my breakpoint.
Once I noticed it hit my breakpoint, I turn on Wifi + disable Airplane mode, then redeployed, it now hits my breakpoint again.

I then headed over to DIPS.Mobile.UI (original project I had issue with), it still has issues and no breakpoint is hit.

This is confusing...

@rolfbjarne
Copy link
Member

This is quite puzzling, but here's an idea to try to fully revert to Xcode 15.4, which involves re-installing the packages from Xcode 15.4 that installs stuff into the system (replacing the ones that were installed by Xcode 16.0).

The packages are in /Applications/Xcode.app/Contents/Resources/Packages, and I believe they have to be installed in a certain order to not fail.

Here's a shell script to do it (make sure to update the path to Xcode):

XCODE=/Applications/Xcode_15.4.0.app
PKGS="MobileDevice.pkg MobileDeviceDevelopment.pkg XcodeSystemResources.pkg"
for pkg in $PKGS; do
	echo "Installing $pkg"
	sudo /usr/sbin/installer -dumplog -verbose -pkg "$XCODE/Contents/Resources/Packages/$pkg" -target /
	echo "Installed $pkg"
done

Warning: I believe this to be safe, but it may leave your system in a confused state where things work worse than before.

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Sep 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed no-auto-reply For internal use need-info Waiting for more information before the bug can be investigated labels Sep 26, 2024
@haavamoa
Copy link
Author

Fortunately, you decided to launch Xcode 16 support with .NET 8, for me this means that I can upgrade to it. Hopefully it will fix things for me :)
I will report back here once I've done so.

@haavamoa
Copy link
Author

haavamoa commented Sep 27, 2024

Alright, good news. This looks like it got resolved.
So I had issues with DIPS.Mobile.UI project yesterday. Today I upgraded to Xcode 16 and the new Workloads. When I started the app, it failed to connect to debugger instantly. I cleaned my bin folders and redeployed. Now it works like it should.
Even disconnecting and reconnecting USB works like before.

I will force this into our pipeline for my colleagues and give feedback here if we notice problems with the new update :)

Have a nice weekend!

@rolfbjarne
Copy link
Member

Alright, good news. This looks like it got resolved. So I had issues with DIPS.Mobile.UI project yesterday. Today I upgraded to Xcode 16 and the new Workloads. When I started the app, it failed to connect to debugger instantly. I cleaned my bin folders and redeployed. Now it works like it should. Even disconnecting and reconnecting USB works like before.

I will force this into our pipeline for my colleagues and give feedback here if we notice problems with the new update :)

Have a nice weekend!

That's great news! Hoping it will stay working 🤞

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Sep 27, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the no-auto-reply For internal use label Sep 27, 2024
@Vetle444
Copy link

Vetle444 commented Oct 1, 2024

@rolfbjarne I still have issues after upgrading to xcode 16 and xamarin.ios 8303. However, it appears it is only reproduced when I am at the office, and not when I am working from home, where I do not have access to our internal network.

It also has nothing to do with disconnecting and reconnecting the usb.

Edit: Looks like I got it working by using the same network on device and mac and then restarting my mac, which I didn't need to before.

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Oct 1, 2024
@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Oct 1, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the no-auto-reply For internal use label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info Waiting for more information before the bug can be investigated
Projects
None yet
Development

No branches or pull requests

3 participants