Skip to content

iOS: new arch: Implementation of prepareForRecycle is fundamentally incorrect #733

@DavidBertet

Description

@DavidBertet

Describe the bug

The new arch implement performance optimization where views are not destroyed but rather reused after they are no longer on screen

prepareForRecycle is called when the component is dismissed, it is designed to reset the view's properties to a default state before it's placed in the recycling pool

Our current implementation is reinstantiating the entire CameraView. While this defeats the whole purpose of the optimization, this is even worst because we don't even know if what's been reinstantiated will even be used at all in the future.

https://github.com/teslamotors/react-native-camera-kit/blob/master/ios/ReactNativeCameraKit/CKCameraViewComponentView.mm#L255

To Reproduce

Steps to reproduce the behavior:

  1. Put a breakpoint in CameraView init
  2. Open camera, breaks a first time - expected
  3. Close camera, breaks a second time - not expected!
  4. Open camera, doesn't break as it's been instantiated when we closed it previous time

Expected behavior

prepareForRecycle should gracefully stop the camera, not recreate everything

@WoLewicki

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions