[WIP] Fix iOS share extension for screenshot preview sharing#86984
Open
[WIP] Fix iOS share extension for screenshot preview sharing#86984
Conversation
Screenshot preview items register images via NSItemProviderWriting with specific types (e.g. public.png). The previous code requested the generic "public.data" type which could fail for these providers. This also fixes handleStringData silently dropping file:// strings without calling completion, which caused the DispatchGroup to hang.
Contributor
|
🚧 @grgia has triggered a test Expensify/App build. You can view the workflow run here. |
Contributor
Author
|
@jjcoffee you can ignore this for now, im testing something |
Contributor
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
53 tasks
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.
Explanation of Change
When sharing a screenshot directly from the iOS screenshot preview thumbnail (the thumbnail that appears after taking a screenshot), iOS provides the image via object-based
NSItemProviderWritingregistration with specific types (e.g.public.png). The share extension'sloadDatamethod was requesting the generic"public.data"type identifier, which could fail for these providers because the type coercion from an object-based registration to the generic data type doesn't always succeed.This PR makes three fixes:
Three-layer loading strategy in
loadData: URLs load viaUTType.url, images load viaUTType.image(handlesUIImage,Data, andURLresults), and a generic fallback usesregisteredTypeIdentifiers.first— the provider's own registered type — which is guaranteed to match.Datahandler inhandleData: Raw byte data (e.g. PNG bytes) is now handled by attemptingUIImageconversion, with a fallback to saving as a generic file.handleStringDatacompletion bug: Previously,file://-prefixed strings were silently dropped without callingcompletion(), which caused theDispatchGroupto hang andopenMainApp()to never execute. Nowfile://strings are properly converted toNSURLand processed throughhandleURLData.Supersedes #84387, which tried four different approaches that all failed on physical devices.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/606736
Tests
Offline tests
N/A — the share extension operates on local data before opening the app.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A — iOS-only change
Android: mWeb Chrome
N/A — iOS-only change
iOS: Native
Requires manual testing on a physical iOS device with the share extension.
iOS: mWeb Safari
N/A — iOS-only change
MacOS: Chrome / Safari
N/A — iOS-only change