Skip to content

fix(share_plus): avoid iOS 26 share sheet crash for non-image files#3813

Open
MohamedAbdallah-14 wants to merge 1 commit intofluttercommunity:mainfrom
MohamedAbdallah-14:fix/share_plus-ios26-crash
Open

fix(share_plus): avoid iOS 26 share sheet crash for non-image files#3813
MohamedAbdallah-14 wants to merge 1 commit intofluttercommunity:mainfrom
MohamedAbdallah-14:fix/share_plus-ios26-crash

Conversation

@MohamedAbdallah-14
Copy link
Copy Markdown

Fixes #3784.

What's wrong

Pre-iOS 26 the plugin used a fake file URL trick to display the file size and extension as a subtitle in the iOS share sheet:

// description = "DOCX • 500 KB"
metadata.originalURL = [NSURL fileURLWithPath:description];

This worked because pre-iOS 26 versions of LinkPresentation accepted any NSURL and only used it for display lookup.

iOS 26 tightened validation of LPLinkMetadata.originalURL. When SHSheetActivityItemsManager asynchronously fetches link metadata for the bogus URL — reproducible when sharing .docx files — LPLinkPreview returns a nil or incomplete metadata object, and _updateMetadataItemForActivityItem:withFetchedMetadata: crashes inserting it into an NSMutableArray:

*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
SHSheetActivityItemsManager -[SHSheetActivityItemsManager _updateMetadataItemForActivityItem:withFetchedMetadata:]
SHSheetActivityItemsManager -[SHSheetActivityItemsManager _fetchMetadataForActivityItem:withHandler:]

Fix

Gate the fake-URL trick on iOS < 26 with @available(iOS 26.0, *). On iOS 26 and later, leave originalURL unset (defaults to nil). The share sheet still works — the title and image preview both still render — but the size/extension subtitle that the fake URL was producing is no longer shown on iOS 26+.

That tradeoff matches what the reporter on #3784 already suggested:

Setting metadata.originalURL = nil instead of the fake path may help.

PDFs and plain text are unaffected, and pre-iOS 26 behaviour is unchanged.

Test plan

  • Manually verify on an iOS 26.x device or simulator: share a .docx file, confirm no crash.
  • Manually verify on an iOS 17 device or simulator: share a .docx file, confirm subtitle still shows ("DOCX • 500 KB").
  • Manually verify on iOS 17 and iOS 26: image sharing still produces a thumbnail preview (metadata.imageProvider path is unaffected).

I do not currently have an iOS 26 simulator to run the repro myself; opening as a draft so a maintainer or CI can validate the iOS 26 behaviour before this is marked ready.

Risks

Related

Fixes fluttercommunity#3784.

Pre-iOS 26 the plugin set LPLinkMetadata.originalURL to a fake file URL
built from a display string (e.g. "DOCX • 500 KB") so the share sheet
would show the file size/extension as a subtitle. iOS 26 tightened
validation of originalURL: when SHSheetActivityItemsManager tries to
fetch link metadata for the bogus URL — reproducible when sharing .docx
files — it crashes with NSArrayM insertObject:atIndex: object cannot be
nil.

Gate the fake-URL trick on iOS < 26. On iOS 26 and later, leave
originalURL unset; the share sheet works without the size subtitle but
no longer crashes.
@MohamedAbdallah-14 MohamedAbdallah-14 force-pushed the fix/share_plus-ios26-crash branch from 947441a to 77a5258 Compare April 28, 2026 19:05
@MohamedAbdallah-14 MohamedAbdallah-14 marked this pull request as ready for review April 29, 2026 02:23
@MohamedAbdallah-14
Copy link
Copy Markdown
Author

The Android API 36 job timed out waiting for the emulator to boot (Timeout waiting for emulator to boot at the getprop sys.boot_completed polling step) — it never reached the test phase. Fail-fast then cancelled API 32, API 29, and the iOS job before they could run.

This PR is iOS-only (FPPSharePlusPlugin.m); no Android code is touched. Could you re-run the failed jobs when you get a chance? The iOS integration test in particular needs to actually execute to validate the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: share_plus iOS 26 crash — NSArrayM insertObject:atIndex: nil object in SHSheetActivityItemsManager when sharing DOCX files

1 participant