Skip to content

iOS Share Sheet Extension crashes on physical device #165086

@vashworth

Description

@vashworth

Steps to reproduce

Putting a flutter screen in an iOS share extension causes it to crash due to exceeded memory limits.

  1. Create a flutter app
  2. Set up share sheet extension (https://docs.flutter.dev/platform-integration/ios/app-extensions#creating-app-extension-uis-with-flutter)
  3. Open project in Xcode
  4. Run on a physical iOS device
  5. Setup debugger for share extension
    5.1. In Xcode > Debug > Attach to Process by PID or Name...
    5.2. Input name of extension
    5.3. Click attach
  6. Open Safari
  7. Click share icon, scroll to the right to "More" with three dots
  8. Find your app and click on it
  9. Flutter screen may or may not show. If it does, try scrolling
  10. App should crash with below message:

Image

Expected results

App should not crash

Apple's documentation states:

Memory limits for running app extensions are significantly lower than the memory limits imposed on a foreground app. On both platforms, the system may aggressively terminate extensions because users want to return to their main goal in the host app.

Your app extension doesn’t own the main run loop, so it’s crucial that you follow the established rules for good behavior in main run loops.

Actual results

App crashes

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) => Scaffold(
        body: ListView.builder(
          itemCount: 100,
          itemBuilder: (context, index) => ListTile(
            title: Text('Item $index'),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Logs

No response

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyteam-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