fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
3.61k stars 254 forks source link

PanicException(failed printing to stdout: Input/ output error (os error 5) #1891

Closed gtmickey closed 3 weeks ago

gtmickey commented 1 month ago

Describe the bug

I have some print code on rust side like

if transfer.is_err() {
        println!("{}", "Transfer failed with error:".to_string().red().bold());
    } else {
        println!("{}", "Transfer successful!".to_string().bright_green().bold());
        println!("Transaction ID:");
    }

When I run on ios debug mode, everything is ok. but when run on ios release mode, error shows, but if I close app then reopen, do same operation, error gone. so It only happen on first time.

Steps to reproduce

build iOS app on release mode, run on physical device, then call some function where contain println! code on rust side.

Logs

PanicException(failed printing to stdout: Input/
output error (os error 5) Backtrace [{ fn:
"std::backtrace::Backtrace::create" 3, { fn: "flutter_rust_brid ge::misc::panic_backtrace::PanicBacktrace::setup:
{{closure}?" 3, { fn: "std::panicking::rust_panic_with_hook" }
{ fn: "std::panicking::begin_panic_handler::{{closure}}" },
{ fn: "std::sys_common::backtrace::rust_end_short_backt
race" 3, {fn: "_rust_begin_unwind" 3, { fn:
"core::panicking::panic_fmt" 3, { fn: "std::o::stdio::_print" 3,
{ fn: "rust_lib_flutter_aleo_rust_lib::archived_aleo::aleo_arc hived_api::do_transfer"}, { fn: "std::panicking::try" 3, { fn:
"<F as threadpool::FnBox>::call_box" 3, { fn: "std::sys_com
mon::backtrace::rust_begin_short_backtrace"}, { fn:
"core::ops::function::FnOnce::call_once{{vtable.shim}?" },
{ fn:
"std::sys::pal::unix::thread::Thread::new::thread
L_start" }])

Expected behavior

No response

Generated binding code

No response

OS

MacOS

Version of flutter_rust_bridge_codegen

2.0.0-dev.30

Flutter info

flutter 3.19.5

Version of clang++

No response

Additional context

No response

fzyzcjy commented 1 month ago

Hmm, I guess that is more like a general Rust + iOS question than a flutter_rust_bridge question, so it may be great to ask there.

That said, here are my two cents: If you want to do logging, here are the docs https://cjycode.com/flutter_rust_bridge/guides/how-to/logging. For example, using approach 1, you can do log::info!("...") instead of println!()

github-actions[bot] commented 1 week ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.