-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: reintroduce macros for FP registration #2027
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
6009187
to
2246cf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
I should've never removed that 😅
We just need to pass options
to the init func then we're good!
__attribute__((constructor)) static void VISION_CONCAT(initialize_, frame_processor_plugin_name)(void) { \ | ||
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@ #frame_processor_plugin_name \ | ||
withInitializer:^FrameProcessorPlugin* _Nonnull(NSDictionary* _Nullable options) { \ | ||
return [[frame_processor_class alloc] init]; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options
need to be passed here as well!
+(void)load { \ | ||
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@ #frame_processor_plugin_name \ | ||
withInitializer:^FrameProcessorPlugin*(NSDictionary * options) { \ | ||
return [[frame_processor_class alloc] init]; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well! options
are not passed.
Maybe we should always have init
/constructors with options, but we can just make them nullable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, let me fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added default - initWithOptions
constructor to the FrameProcessorPlugin
class, so users may override it to consume that options
object. Also it seems that object wasn't marked in TypeScript, so I added it and adjusted rest of iOS/Android code to consume it properly. Let me know if it's ok
2246cf5
to
a69ce1e
Compare
in VisionCamera v1 & v2 there were two ObjC macros that were helping in creation/registration of Frame Processors, but these were removed with v3 This PR reintroduces such macros, which will not only make FP development easier, but also it will also fix issues people had with registration of Swift Frame Processors (+load vs +initialize issues) Docs were also updated to reflect that the macros should be used to correctly initialize and register ObjC/Swift Frame Processors
a69ce1e
to
ba43e89
Compare
I prepared corresponding PR for the plugin builder CLI, ping me when this PR will be merged and included in next release |
ExampleFrameProcessorPlugin() { | ||
|
||
ExampleFrameProcessorPlugin(@Nullable Map<String, Object> options) { | ||
Log.d("ExamplePlugin", " - options: " + options.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will crash if it's null, but I'll fix it dw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff Mateusz!!!!! Thank you ❤️
…usavy#2027) in VisionCamera v1 & v2 there were two ObjC macros that were helping in creation/registration of Frame Processors, but these were removed with v3 This PR reintroduces such macros, which will not only make FP development easier, but also it will also fix issues people had with registration of Swift Frame Processors (+load vs +initialize issues) Docs were also updated to reflect that the macros should be used to correctly initialize and register ObjC/Swift Frame Processors
What
in VisionCamera v1 & v2 there were two ObjC macros that were helping in creation/registration of Frame Processors, but these were removed with v3
This PR reintroduces such macros, which will not only make FP development easier, but also it will also fix issues people had with registration of Swift Frame Processors (+load vs +initialize issues)
Docs were also updated to reflect that the macros should be used to correctly initialize and register ObjC/Swift Frame Processors
Changes
Tested on
iPhone 12 Pro
Related issues
Similar change regarding the Swift FP registration is made for V2 branch - #2025