Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no reactor running, must be called from the context of a Tokio 1.x runtime #2148

Closed
Larpoux opened this issue Jun 23, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Larpoux
Copy link
Contributor

Larpoux commented Jun 23, 2024

Describe the bug

Panic at src/api/override_web_audio_api.rs:124
When I set a callback function for the endedevent of my audio_buffer_source node.

Steps to reproduce

  Future<void> finished(Event event) async
  {
    Tau.tau.logger.d('lolo');
    await stop();
  }
....
src = await audioCtx.createBufferSource();
...
await src.setOnEnded(callback: finished);

override_web_audio_api.rs:124

handle_audio_scheduled_source_node_trait_impls_override!(AudioBufferSourceNode);

Logs

'<unnamed>' panicked at src/api/override_web_audio_api.rs:124:1:
there is no reactor running, must be called from the context of a Tokio 1.x runtime
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_display
   3: tokio::task::spawn::spawn_inner::panic_cold_display
   4: tokio::task::spawn::spawn_inner
   5: tokio::task::spawn::spawn
   6: <web_audio_api::node::audio_buffer_source::AudioBufferSourceNode as tau::api::override_web_audio_api::AudioBufferSourceNodeScheduledSourceNodeMiscExt>::set_on_ended::{{closure}}
   7: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
   8: web_audio_api::node::scheduled_source::AudioScheduledSourceNode::set_onended::{{closure}}
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
  10: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
  11: web_audio_api::events::EventLoop::handle_event
  12: web_audio_api::events::EventLoop::run_in_thread::{{closure}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

OS

Macos

Version of flutter_rust_bridge_codegen

flutter_rust_bridge_codegen 2.0.0

@Larpoux Larpoux added the bug Something isn't working label Jun 23, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 23, 2024

Ok I guess that's because of something like:

flutter_rust_bridge::spawn(async move { callback(event).await });
(and various other places). I did not run them before (since that was just a prototype). I will check it a bit later.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 24, 2024

PR: #2151 (Just copy-paste the update code after it is done)

I have not run it to test whether it is fixed though, since integrate_third_party does not contain things to be run but only things at compile time.

@Larpoux
Copy link
Contributor Author

Larpoux commented Jun 27, 2024

It works much better.

await src.setOnEnded(callback: finished)

The callback is correctly called at the end of the playback. 🥇

@Larpoux Larpoux closed this as completed Jun 27, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 27, 2024

Looks great!

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants