thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
64 stars 4 forks source link

Debugging Rust code #65

Open MGlolenstine opened 2 years ago

MGlolenstine commented 2 years ago

Is there a way to debug both Rust and Dart code at the same time?

Rust, for example does support FFI debugging when it's loading in a native library. I'm wondering what has to be done to enable the Rust debugging while Dart/Flutter project is running.

thlorenz commented 1 year ago

I do not think this is possible as the rust code is loaded via a lib into the flutter app. The only thing I could imagine is to make it easy to leverage the rust code directly via an app that behaves like the flutter app, but is authored in rust as well. Maybe this could be achieved via the bevy library? In any case it'd be quite a task to implement. For now I'd recommend unit testing the rust code instead and debugging the running tests if needed.

MGlolenstine commented 1 year ago

That's what I went with in the end. I also implemented a logging "framework" that sends data to Dart for printing them out to the console.

While I do love working with Rust and Flutter, I'm happy that the RID part is over. Looking back, it's bitter sweet experience, great on one hand, but then a bug would cause me to lose a day. Most of the bugs were present in code that was unable to be unit tested and I spent most time on those bugs. Now that I'm through that, it's been smooth sailing.

(Not going to mention that I spawned few isolates and spent about a week debugging why store wasn't updating... (It's because each isolate spawned its own Store, which kinda worked, but not really.))

I really appreciate RID, as it saved us tons of time and effort that would've gone into porting our Rust lib to Dart.

thlorenz commented 1 year ago

Sorry you ran into these issues. I'd love to see a blog post about your experience esp. how you overcame some challenges.

Does this mean you won't reach for rid in the future? You could also include that in the post so others can make a good decision for themselves. I do realize that working with two techs in one project that are held together via FFI can be challenging.

MGlolenstine commented 1 year ago

I will reach for RID in the future, just not for a project this massive. Now that I know its quirks, it'll be much easier to use.

About the blog. I was thinking of starting one for ages, and now is as good time as any.