Skip to content

fix: iOS SIGABRT in TryLoadFromPatch when native iOS plugins spawn headless FlutterEngine (native_geofence) #3634

@garri1105

Description

@garri1105

App ID: 8af68145-6577-4dec-a5c9-c503349f4708

Description

We are experiencing a hard crash (fml::KillProcess()) in production when using native_ iOS plugins that handle background execution by spawning a secondary, headless FlutterEngine (specifically, native_geofence).

When the app is already running and patched via Shorebird, and a native iOS plugin forcefully instantiates a new FlutterEngine (using createFlutterEngine), Shorebird's TryLoadFromPatch attempts to load the patch for this secondary engine. It encounters a fatal error during DartSnapshot::IsolateSnapshotFromSettings and kills the entire process.

** Expected Behavior: **
While we understand that native plugins probably shouldn't start a whole new engine for background tasks, Shorebird should ideally fail gracefully here rather than taking down the entire application. If the patch cannot be safely applied to a secondary raw engine, can Shorebird fallback to the base snapshot or log a non-fatal error instead of invoking fml::KillProcess()?

Stack Trace:

Plaintext
3 Flutter fml::KillProcess()
4 Flutter fml::LogMessage::~LogMessage()
6 Flutter flutter::TryLoadFromPatch (patch_cache.cc:148)
7 Flutter flutter::ResolveIsolateData (dart_snapshot.cc:223)
8 Flutter flutter::DartSnapshot::IsolateSnapshotFromSettings
9 Flutter flutter::Shell::InferVmInitDataFromSettings
10 Flutter flutter::Shell::Create
11 Flutter -[FlutterEngine createShell:libraryURI:initialRoute:]
12 Flutter -[FlutterEngine runWithEntrypoint:libraryURI:initialRoute:entrypointArgs:]
13 native_geofence LocationManagerDelegate.createFlutterEngine()
Environment:

Shorebird 1.6.80
Flutter 3.38.9

Steps To Reproduce

  1. Deploy a patch on an app that has configured native_geofence
  2. See the app crash when the new patch is downloaded

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions