-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Consider exposing plugin APIs for use via FFI #110353
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
Comments
Curious -- would |
In the particular case of this one API in this one use case, you could get correct behavior in most cases by guessing that the active window is the one showing the dialog. There's no guarantee that that's true though. And it definitely doesn't generalize to, for instance, the texture registry. |
I am going down a big rabbit hole, because I don't understand graphics or the flutter engine too well. Would appreciate any help at all :) I was going to use FFI from flutter/dart to my rust code that captures video frames using gstreamer. With rust, I want to stream frames/pixel buffers to the texture registry. I need to render local video and then as an extension should be able to render incoming UDP bytes using the same pattern. Am I correct that based on this discussion, that I am down the wrong path? Would you suggest some sort of workaround? Thank you so much! |
There is currently no built-in way to access the texture registry directly from FFI, nor are they threadsafe unless specfically noted (and FFI calls will not run on the platform thread).
You could either write a standard Flutter plugin that calls your Rust code, or you could design your own system in native code for making tetxtures accessible to FFI (e.g., by indirecting through a global that you design that store references and manages cross-thread dispatching). |
This comment was marked as off-topic.
This comment was marked as off-topic.
This would help development a lot, the only kotlin part of my android app is for texture registry |
dart:ffi has currently only basic interop and can't be used for textures. - flutter/flutter#52229 - flutter/flutter#110353
What are the blockers for this? It sounds like one issue is thread safety, but we have |
It needs a design for what exactly we are going to expose (e.g., is it the entire registrar surface? how do we adapt the API given that it's designed as a per-plugin interface, but there's no plugin instance in this use case? or do we require a |
Here is the set of issues I've identified that would need to be resolved in order to use the texture APIs on iOS entirely via FFI, with no plugin component (a subset of this issue, but an illustrative one):
I'll flesh this out more in a design document, where we can explore technical solutions and file more specific follow-up issues, but I wanted to capture the issues here at a high level. |
Just to clarify, |
Ah, thanks for clearing up my misunderstanding! I'll play around with trying to find a pattern for driving the texture updates from a background isolate. |
I ran into a dead-end on this because |
What sort of stuff would that callback need to do? Would it run arbitrary user code, or code that the flutter team owns? @aam is working on a variant of |
This is a plugin API, so the code is arbitrary user code. In practice, I would guess that the use cases for the texture API would mostly be similar to what |
Currently FFI can be used as an alternative to normal plugin structure for some use cases, but anything that requires access to plugin APIs—things exposed via the plugin registry, such as texture registration, or accessing the native view on desktop—requires using the normal plugin flow and method channels.
We should investigate whether there's a reasonable way to expose at least some of that functionality via APIs that are accessible via FFI.
As an example use case, if we wanted to convert
file_selector_windows
it should be mostly doable via thewin32
package, but we need access to the nativeHWND
to show the dialog in the correct location, and that's currently only accessible via the plugin registry.The text was updated successfully, but these errors were encountered: