Dropsource / monarch

Monarch is a tool for building Flutter widgets in isolation. It makes it easy to build, test and debug complex UIs.
https://monarchapp.io
MIT License
427 stars 21 forks source link

DevTools attach to main monarch app instead of a story #135

Open ezmegy opened 8 months ago

ezmegy commented 8 months ago

I can't seem to debug any stories in DevTools. Not sure yet if this is a bug or just me missing something though...

Whenever I press the "Launch DevTools..." button, it seems to attach to the main Monarch app instead of the story and I can only debug that but not stories.

I have monarch v3.7.0 flutter package and v2.2.2 binary installed on a Mac.

Minimal repro:

In DevTools, Flutter Inspector

See the screenshots of these below.

I've tried restarting/reloading the stories and DevTools, didn't seem to help.

Any pointers what could be wrong?

Screenshot 2023-11-07 at 11 12 15

Screenshot 2023-11-07 at 11 13 07

fertrig commented 8 months ago

Can you quit Monarch ⌃C on your terminal and then run it again? I remember seeing this issue in older Flutter versions. However, this issue was not consistent. You may need to try a couple of times until DevTools attaches to your stories.

I just tried it on Flutter 3.13.6 on macOS without issues. Attaching and debugging stories worked as expected.

ezmegy commented 8 months ago

Thanks for the quick response!

Looks like the Flutter version does matter indeed.

v3.13.6 -> works fine v3.13.7 -> issue - was on this originally, quitting/restarting monarch didn't help v3.13.9 -> same issue

Will try and test/dig a bit more...

fertrig commented 8 months ago

I had documented this issue and its workaround on the code:

https://github.com/Dropsource/monarch/blob/c36e271a93ba484171146c08a54449e85665b266/platform/macos/monarch_macos/WindowManager.swift#L121-L130

The workaround had been working but I think it is time to look into a proper fix.