Skip to content

Retain Cycle Issue in iOS #2462

Open
Open

Description

@RK114290

Bug Report

The bridge.viewController is not getting released since this plugin hold the strong Reference to the ViewController
on load(), which is leading to retain cycle in iOS .

https://github.com/ionic-team/capacitor-plugins/blob/7.x/screen-orientation/ios/Sources/ScreenOrientationPlugin/ScreenOrientationPlugin.swift

Inside this class :

https://github.com/ionic-team/capacitor-plugins/blob/7.x/screen-orientation/ios/Sources/ScreenOrientationPlugin/ScreenOrientation.swift

Please change view controller to weak :

private weak var capViewController: CAPBridgeViewController?

Plugin(s)

Plugin : screen-orientation

https://github.com/ionic-team/capacitor-plugins/blob/main/screen-orientation/ios/Sources/ScreenOrientationPlugin/ScreenOrientation.swift

Platform(s)

iOS

Expected Behavior

It should be able to access the bridge.viewController as long as it stays in memory

Or

Please provide option or method to close ViewController safely without memory leaks .

Additional :

Same issue is observed with capacitor-barcode-scanner in load() , it passes viewController reference to OSBarcodeLib which strongly holds the viewController

https://github.com/ionic-team/capacitor-barcode-scanner/blob/main/plugin/ios/Sources/CapacitorBarcodeScannerPlugin/CapacitorBarcodeScannerPlugin.swift

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