Skip to content

FlutterUndoManagerPlugin is not released causes the crash (when not initializing FlutterEngine in global scope) #150408

@dullgrass

Description

@dullgrass

Steps to reproduce

  1. Enter the Flutter page,
  2. manipulate the TextView, perform copy and paste operations, generate undo actions,
  3. exit the Flutter page, and then perform a three-finger slide to undo

Expected results

not crash

Actual results

crash,The root cause is that the FlutterUndoManagerPlugin is not released, while the FlutterEngine has already been released. Attempting to send a message to an object that has been released leads to a crash. In this scenario, the question is whether the FlutterUndoManagerDelegate within FlutterUndoManagerPlugin can be marked with weak.

Code sample

@implementation [FlutterUndoManagerPlugin](https://api.flutter.dev/ios-embedder/interface_flutter_undo_manager_plugin.html) {
   id<FlutterUndoManagerDelegate> _undoManagerDelegate;
 }
  
 - (instancetype)initWithDelegate:(id<[FlutterUndoManagerDelegate](https://api.flutter.dev/ios-embedder/protocol_flutter_undo_manager_delegate-p.html)>)undoManagerDelegate {
   self = [super init];
  
   if (self) {
     // `_undoManagerDelegate` is a weak reference because it should retain FlutterUndoManagerPlugin.
     _undoManagerDelegate = undoManagerDelegate;
   }
  
   return self;
 }

Screenshots or Video

Screenshots / Video demonstration

1718703139514

Logs

Logs
[Paste your logs here]

Flutter Doctor output

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: existing-appsIntegration with existing apps via the add-to-app flowengineflutter/engine related. See also e: labels.found in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions