Skip to content

iOS: shape animator TurboModules return another module's SpecJSI, crashing on first call (New Architecture) #4301

Description

@mohdayanansari

Version

@rnmapbox/maps 10.3.5, React Native 0.86.2, Expo SDK 57, New Architecture (RN 0.86 has no old architecture to fall back on).

What happens

Calling __experimental.MovePointShapeAnimator on iOS takes the app down at the first call — the new MovePointShapeAnimator([lng, lat]) that reaches NativeRNMBXMovePointShapeAnimatorModule.generate. Android is unaffected.

Cause

Both iOS shape-animator modules return another module's generated spec from getTurboModule::

ios/RNMBX/ShapeAnimators/RNMBXMovePointShapeAnimatorModule.mm

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
    (const facebook::react::ObjCTurboModule::InitParams &)params
{
    return std::make_shared<facebook::react::NativeRNMBXPointAnnotationModuleSpecJSI>(params);
}

ios/RNMBX/ShapeAnimators/RNMBXChangeLineOffsetsShapeAnimatorModule.mm returns NativeRNMBXShapeSourceModuleSpecJSI in the same place.

Every other module in the package returns its own spec (RNMBXCameraModule, RNMBXImageModule, RNMBXShapeSourceModule, RNMBXViewportModule, RNMBXPointAnnotationModule), so these two look like a copy-paste slip. The effect is that the module is registered but answers to a spec that does not declare generate / moveTo.

The Kotlin modules are registered correctly, which is why this is invisible on Android.

Fix

--- a/ios/RNMBX/ShapeAnimators/RNMBXMovePointShapeAnimatorModule.mm
+++ b/ios/RNMBX/ShapeAnimators/RNMBXMovePointShapeAnimatorModule.mm
-    return std::make_shared<facebook::react::NativeRNMBXPointAnnotationModuleSpecJSI>(params);
+    return std::make_shared<facebook::react::NativeRNMBXMovePointShapeAnimatorModuleSpecJSI>(params);

--- a/ios/RNMBX/ShapeAnimators/RNMBXChangeLineOffsetsShapeAnimatorModule.mm
+++ b/ios/RNMBX/ShapeAnimators/RNMBXChangeLineOffsetsShapeAnimatorModule.mm
-    return std::make_shared<facebook::react::NativeRNMBXShapeSourceModuleSpecJSI>(params);
+    return std::make_shared<facebook::react::NativeRNMBXChangeLineOffsetsShapeAnimatorModuleSpecJSI>(params);

Both spec names come straight from src/specs/NativeRNMBXMovePointShapeAnimatorModule.ts and src/specs/NativeRNMBXChangeLineOffsetsShapeAnimatorModule.ts, and match the naming of the generated Android specs. Happy to send this as a PR if that is easier.

Reproduction

Any New-Architecture iOS app that renders a ShapeSource whose shape is a MovePointShapeAnimator:

const animator = new __experimental.MovePointShapeAnimator([lng, lat]);
<Mapbox.ShapeSource id="v" shape={animator}>
  <Mapbox.CircleLayer id="dot" style={{ circleRadius: 8 }} />
</Mapbox.ShapeSource>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions