Skip to content

Commit

Permalink
fix: Fix correct Frame Processor loading between Objc/Swift (#2025)
Browse files Browse the repository at this point in the history
* test: add failing test to ensure swift/objc fp works

* refactor: emit type of FP from each example

* fi: objc can use load, not initialize

* fix: swift should use attribute(constructor)

* chore: update example ios lockfile

* fix: remove context tagged payloads for example

* Revert "test: add failing test to ensure swift/objc fp works"

This reverts commit ba01d28.
  • Loading branch information
iBotPeaches authored Oct 18, 2023
1 parent 984499e commit f5b6d7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ @implementation ExampleFrameProcessorPlugin
static inline id example_plugin(Frame* frame, NSArray* arguments) {
CVPixelBufferRef imageBuffer = CMSampleBufferGetImageBuffer(frame.buffer);
NSLog(@"ExamplePlugin: %zu x %zu Image. Logging %lu parameters:", CVPixelBufferGetWidth(imageBuffer), CVPixelBufferGetHeight(imageBuffer), (unsigned long)arguments.count);

for (id param in arguments) {
NSLog(@"ExamplePlugin: -> %@ (%@)", param == nil ? @"(nil)" : [param description], NSStringFromClass([param classForCoder]));
}

return @{
@"example_str": @"Test",
@"example_bool": @true,
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ PODS:
- React-Core
- RNVectorIcons (9.2.0):
- React-Core
- VisionCamera (2.16.0):
- VisionCamera (2.16.3):
- React
- React-callinvoker
- React-Core
Expand Down Expand Up @@ -599,9 +599,9 @@ SPEC CHECKSUMS:
RNScreens: 6a8a3c6b808aa48dca1780df7b73ea524f602c63
RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8
RNVectorIcons: fcc2f6cb32f5735b586e66d14103a74ce6ad61f8
VisionCamera: 46a12d82bb9ac6c03b3a54c3530a810496112d96
VisionCamera: 38fb9fae2d3e2fccac46a365e675c045b4e52d0f
Yoga: 39310a10944fc864a7550700de349183450f8aaa

PODFILE CHECKSUM: c9a6f4676a612af372440732ecc8fae75b559be7

COCOAPODS: 1.12.1
COCOAPODS: 1.11.2
12 changes: 5 additions & 7 deletions ios/Frame Processor/FrameProcessorPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
#define VISION_EXPORT_FRAME_PROCESSOR(frame_processor) \
\
+(void)initialize \
+(void)load \
{ \
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@"__" @ #frame_processor callback:^id(Frame* frame, NSArray<id>* args) { \
return frame_processor(frame, args); \
Expand All @@ -53,13 +53,11 @@ objc_name : NSObject<FrameProcessorPluginBase>
@end \
@implementation objc_name (FrameProcessorPlugin) \
\
+(void)initialize \
__attribute__((constructor)) static void VISION_CONCAT(initialize_, objc_name)() \
{ \
if (self == [objc_name class]) { \
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@"__" @ #name callback:^id(Frame* frame, NSArray<id>* args) { \
return [objc_name callback:frame withArgs:args]; \
}]; \
} \
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@"__" @ #name callback:^id(Frame* frame, NSArray<id>* args) { \
return [objc_name callback:frame withArgs:args]; \
}]; \
}

#endif /* FrameProcessorPlugin_h */

0 comments on commit f5b6d7e

Please sign in to comment.