fix(share_plus): avoid iOS 26 share sheet crash for non-image files#3813
Open
MohamedAbdallah-14 wants to merge 1 commit intofluttercommunity:mainfrom
Open
fix(share_plus): avoid iOS 26 share sheet crash for non-image files#3813MohamedAbdallah-14 wants to merge 1 commit intofluttercommunity:mainfrom
MohamedAbdallah-14 wants to merge 1 commit intofluttercommunity:mainfrom
Conversation
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.
947441a to
77a5258
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
This worked because pre-iOS 26 versions of
LinkPresentationaccepted anyNSURLand only used it for display lookup.iOS 26 tightened validation of
LPLinkMetadata.originalURL. WhenSHSheetActivityItemsManagerasynchronously fetches link metadata for the bogus URL — reproducible when sharing.docxfiles —LPLinkPreviewreturns anilor incomplete metadata object, and_updateMetadataItemForActivityItem:withFetchedMetadata:crashes inserting it into anNSMutableArray:Fix
Gate the fake-URL trick on iOS < 26 with
@available(iOS 26.0, *). On iOS 26 and later, leaveoriginalURLunset (defaults tonil). 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:
PDFs and plain text are unaffected, and pre-iOS 26 behaviour is unchanged.
Test plan
.docxfile, confirm no crash..docxfile, confirm subtitle still shows ("DOCX • 500 KB").metadata.imageProviderpath 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
originalURLvalues, this gate could be removed; for nowiOS 26.0is the safe lower bound based on the reproduction in [Bug]: share_plus iOS 26 crash — NSArrayM insertObject:atIndex: nil object in SHSheetActivityItemsManager when sharing DOCX files #3784.Related
sharePositionOrigin(PR fix(share_plus): avoid crash on iOS 26 on iPads with no sharePosition… #3769).sharePositionOrigin must be setcrash.