AvdLee / RocketSimApp

Enhancing the iOS simulator for productivity
605 stars 20 forks source link

Tapping on menu bar item hangs my M1 MacBook for multiple seconds #457

Closed KaiOelfke closed 7 months ago

KaiOelfke commented 8 months ago

Describe the bug My M1 MacBook hangs for multiple seconds and shows a beach ball after tapping on the rocket sim menu bar icon. Subsequent taps are immediate as normal. Changing the active / focused app slows down tapping the menu bar item again.

To Reproduce Steps to reproduce the behavior:

  1. Launch RocketSim
  2. No Xcode running or simulator (not sure if it matters)
  3. Tap on rocket sim menu bar
  4. Change active app e.g. open mail or a browser
  5. Repeat step 3 and 4 to reproduce multiple times

Expected behavior

I expect the menu bar item to always open immediately.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

AvdLee commented 7 months ago

@KaiOelfke would you be able to share a Diagnostics Report via Settings -> About -> Report an Issue?

I'm sorry for this inconvenience, I'd love to find out the cause!

markrenaud commented 7 months ago

I am having the same issue (with the same steps to reproduce) on y M1 Max MacBook Pro. It is very frustrating. I would be happy to share a Diagnostic Report, but as I only use web based email (no client on my computer) - clicking on the Report an Issue? menu just tries to open Mail (which is not setup). I was unable to find an email address to send the report to in the docs.

Desktop (please complete the following information):

OS: 14.2.1 (23C71) Version: Version 12.6.4 (199)

AvdLee commented 7 months ago

@markrenaud sorry for that!

You can right-click the report an issue button to save the file to disk. That way, you can upload the DR to any email provider:

CleanShot 2024-02-18 at 13 25 33@2x

Thanks a lot for helping out, I'm trying to find the cause as we speak!

AvdLee commented 7 months ago

Additional question: does this happen directly after a fresh launch? Or only after having RocketSIm open for a while?

markrenaud commented 7 months ago

Sorry for the delay in replying, and thank you for looking into the issue.

The problem can occur after a fresh launch. Simply bringing another app to the foreground before clicking on the menu bar item is enough to cause the hang.

For example:

Interestingly, sometimes when switching the foreground app back to Xcode, the hang doesn't occur on the next click of the menu bar app. This behavior is unique to switching back to Xcode - switching to any other app in the foreground always causes the hang.

The hang blocks all of macOS UI (I can't even type anything anywhere, can't use Finder, etc.).

I will try to send a Diagnostics report when I get a chance.

PS. I just updated to version 12.6.5 (200), and the issue still occurs.

AvdLee commented 7 months ago

@markrenaud thanks a lot for those insights. A Diagnostics report would be amazing. I feel like there's some heavy main-thread work happening. Potentially, it's a network request that does work great from my machine, but might have much slower response in other regions. Thinking out loud here, but a Diagnostics Report will definitely give better insights! 🙏

markrenaud commented 7 months ago

@AvdLee I sent a diagnostics report and a video of the issue to you yesterday at the email: support@rocketsim.app - please let me know it this didn't come through, and I can resend to an email of your choice.

markrenaud commented 7 months ago

@AvdLee, just another thought - does the app scan for available run destinations (or try to probe them somehow) when you click on the menu bar? I have noticed issues with Xcode physical device run destinations that are able to "Connect via network" (in the Devices & Simulators window) being slow to resolve information in other scenarios. I wonder if this may be part of the issue - and if it is, it may be related to the issue here: https://developer.apple.com/forums/thread/737875. I was intrigued to learn in this thread that iOS 17 has a new debugging infrastructure such that all debugging goes over the network. When you mentioned a network request, I wondered what sort of network request is being sent with each click of the menu bar app icon - it got me thinking about this issue.

Please let me know if you require any further testing on my end. I'm currently working on some app functionality that requires location services, and RocketSim's ability to quickly change simulator locations is amazing (but frustrating with the hang).

markrenaud commented 7 months ago

Here's some additional information for you - beyond the video and diagnostics report emailed, I've also attached a spindump for RocketSim that captured a 10-second period while I was triggering the hang.

It certainly seems to be doing a lot of work during the hang: RocketSim: CPU Time: 5.416s (17.0G cycles, 59.4G instructions, 0.29c/i)

For comparison, the next closest app in terms of CPU time was ActivityMonitor (which I would expect to be doing more cycles than simply clicking on the RocketSim menu bar app). ActivityMonitor: CPU Time: 0.284s (358.4M cycles, 704.8M instructions, 0.51c/i)

I'm no spindump expert, but it appears that there is a significant amount of work being done in enumerating directories when clicking on the RocketSim menu bar icon. Perhaps this directory enumeration is causing issues.

Apologies for the multiple messages. rocketsim-spindump.txt

AvdLee commented 7 months ago

@markrenaud thanks a lot for sharing all this information, including the email earlier! This will greatly help me find the cause. It's my top priority this week.

What would also help is opening Console.app and filtering on process:RocketSim

  1. Close RocketSim
  2. Open Console.app and filter on process:RocketSim
  3. Open RocketSim
  4. Reproduce the issue
  5. Close RocketSim
  6. Export the logs and email them

That's likely going to give me extra tools to find out the cause.

Lastly: the video & Diagnostics report are great. However, it seems that the Diagnostics Report does not contain the session from the video. Therefore, could you:

  1. Close RocketSim
  2. Open RocketSim
  3. Reproduce the issue
  4. Close RocketSim
  5. Open RocketSim
  6. Share the Diagnostics Report

That way, the before last session in the Diagnostics Report will tell me exactly which logs and potentially requests caused the delay.

Hope you don't mind these extra requests, your feedback is extremely helpful in getting this fixed! 🙏

markrenaud commented 7 months ago

@AvdLee I have emailed the requested reports and some additional information. 😄

AvdLee commented 7 months ago

I might have fixed your issue. I can’t narrow down exactly where it might have performance issues, but this is my hypothesis:

The fix I did is to cache applications and only refresh them if the modification date for the application folder changes.

I’m hoping to ship a fix in the coming days, so stay tuned!