rust-mobile / android-activity

Glue for building Rust applications on Android with NativeActivity or GameActivity
238 stars 46 forks source link

Stop log-forwarding thread on IO errors #133

Closed MarijnS95 closed 9 months ago

MarijnS95 commented 11 months ago

Fixes #132

When read_line() starts returning Err the current if let Ok condition ignores those, likely causing the loop to spin indefinitely while this function keeps returning errors.

Note that we don't currently store the join handle for this thread anywhere, so won't see the error surface either (just like how the join handle for the main thread is never checked). Perhaps we should call log::error!() to make the user aware that their IO logging has mysteriously terminated.

MarijnS95 commented 10 months ago

@rib we probably want to have this in so that I can test rustix on top.

MarijnS95 commented 9 months ago

but it could be nice if we'd log some kind of clue if you hit a spurious error here

Done.

If you want to leave that for a separate follow up that's ok though.

Let's leave stopping+joining the thread for a followup, as we'd have to close stdin/stdout - hoping they haven't been dup2()'d elsewhere - to trigger a len == 0read and exit the thread before calling.join()`.

Not required but it could also be nice to share a utility for spawning this stdio thread since the code is identical between the two backends.

Done, good idea. The util module already exists for exactly this purpose anyway.

MarijnS95 commented 9 months ago

Yeah I hope @fornwall doesn't mind some preliminary conflict resolution... Though I can revert it.

fornwall commented 9 months ago

Yeah I hope @fornwall doesn't mind some preliminary conflict resolution... Though I can revert it.

Absolutely no problem, I'll fix!