ionic-team / ionic-team/capacitor-plugins
Retain Cycle Issue in iOS
- Dominant language
- Java
- Stars
- 678
- Forks
- 685
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 3
Description
## 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
Contributor guide
Assessment
This issue has not been assessed yet.