PKBeam / AMWin-RP

A Discord Rich Presence client for Apple Music's native Windows app.
GNU General Public License v3.0
460 stars 27 forks source link

NullReferenceException in `GetAppleMusicInfo` in 1.3.0b1 #75

Closed SWiegandt closed 8 months ago

SWiegandt commented 8 months ago

Version Info 1.3.0b1

Describe the bug I'm intermittently getting

[04:55:26] Something went wrong while scraping: System.NullReferenceException: Object reference not set to an instance of an object.
   at AMWin_RichPresence.AppleMusicClientScraper.GetAppleMusicInfo()
   at AMWin_RichPresence.AppleMusicClientScraper.Refresh(Object source, ElapsedEventArgs e)
[05:49:55] Previous message repeated 653 times

using the latest beta, which I'm guessing has to do with the change in automation library. After getting the error once it seems to keep happening until restarting Apple Music (restarting AMWin-RP doesn't help), and I haven't been able to narrow down what causes it to start. Is it possible to log a more granular error message saying exactly what line reports the error?

SWiegandt commented 8 months ago

One way of triggering it is opening the properties popup window for a song, so I'm guessing there are some assumptions made about the active AM window somewhere that break when the active window isn't the main one?

e: Actually, it seems to be the right-click context menu rather than the popup window itself that causes it (or maybe both, but I don't think there's another way of opening another window than with a context menu).

PKBeam commented 8 months ago

seems to be an issue with the descendant traversal of the UI library: https://github.com/FlaUI/FlaUI/issues can probably make a workaround for this.

PKBeam commented 8 months ago

implemented a manual BFS for descendant nodes - this should fix the problem.

SWiegandt commented 8 months ago

Seems to be working 👍