{ "id": "176276", "key": "TIMOB-28532", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "21265", "description": "", "name": "Release 10.1.1", "archived": false, "released": true, "releaseDate": "2021-11-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2021-10-05T11:22:50.000+0000", "created": "2021-08-28T21:55:39.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "ios", "media", "openPhotoGallery", "photogallery" ], "versions": [], "issuelinks": [ { "id": "59324", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "157794", "key": "TIMOB-21844", "fields": { "summary": "Ti.Media Test Suite: Titanium.Media Acceptance TIMOB-5970", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "None", "id": "6" }, "issuetype": { "id": "10100", "description": "This Issue Type is used to create Zephyr Test within Jira.", "name": "Test", "subtask": false } } } }, { "id": "59319", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "175964", "key": "TIMOB-28320", "fields": { "summary": "Ti.UI.Window Test Suite: Titanium.UI.Window Acceptance TIMOB-28067 iOS Only", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "None", "id": "6" }, "issuetype": { "id": "10100", "description": "This Issue Type is used to create Zephyr Test within Jira.", "name": "Test", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2021-11-17T10:46:32.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h2. Bug\r\nIf a user swipes down a gallery in iOS, the second time I open programmatically the photo gallery, an error is thrown and the error callback is called. This doesn’t happen when the user clicks cancel: the cancel callback is called and the second time the user opens the gallery no error is thrown.\r\n\r\nOther kind users of the ti.slack community have investigated this issues and reached the same conclusions. One of them in particular suggested a (working) fix.\r\n\r\nJason David Miller wrote:\r\n{quote}I can confirm that it's happening with TiSDK 10.1.0.v20210824071502 . The very first time Ti.Media.openPhotoGallery() is called, all works well. If the user clicks 'cancel', the gallery hides and the cancel method is called. However, if the user simply swipes down to cancel (normal iOS 14+ behavior), the gallery does not call the cancel method and an error is thrown when attempting to call Ti.Media.openPhotoGallery() again. — Also, it takes two clicks to open the gallery again (after hidden via swipe). I'm assuming that since the gallery's success, cancel, or error methods aren't being called, maybe iOS assumes the gallery is still shown and/or hasn't been deallocated).\r\nSummary: it seems like the 'swipe down to cancel' needs to actually call the cancel method (in TiSDK), although I'm unsure if that's currently the case...\r\n{quote}\r\n\r\n*Example Code*\r\n\r\n{code:javascript}\r\nTi.Media.openPhotoGallery({\r\n success: (e) => {\r\n Ti.API.info('Photo gallery success: ', e);\r\n },\r\n cancel: () => {\r\n Ti.API.warn('Photo gallery cancel');\r\n },\r\n error: (error) => {\r\n Ti.API.error('Photo gallery error: ', error);\r\n },\r\n autohide: true,\r\n allowEditing: false,\r\n saveToPhotoGallery: false,\r\n mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],\r\n videoQuality: Ti.Media.QUALITY_HIGH\r\n});\r\n{code}\r\n\r\nso it looks like presentationControllerDidDismiss is not being called when the photo gallery is dismissed via swipe (being pulled down)...\r\n*/iphone/Classes/MediaModule.m*\r\n{code:objective-c}\r\n#if IS_SDK_IOS_13\r\n- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController\r\n{\r\n#if defined(USE_TI_MEDIASHOWCAMERA) || defined(USE_TI_MEDIAOPENPHOTOGALLERY) || defined(USE_TI_MEDIASTARTVIDEOEDITING)\r\n#if IS_SDK_IOS_14 && defined(USE_TI_MEDIAOPENPHOTOGALLERY)\r\n [self closeModalPicker:picker ?: _phPicker];\r\n#else\r\n [self closeModalPicker:picker];\r\n#endif\r\n [self sendPickerCancel];\r\n#endif\r\n}\r\n#endif\r\n{code}\r\n\r\nh2. Proposed solution\r\nMarc Bender proposed this solution\r\n{quote}I found the problem!\r\nadd these lines in the phpickerdeledate:\r\n{quote}\r\n{code:objective-c}\r\n#pragma mark PHPickerViewControllerDelegate\r\n- (void)presentationControllerDidDismiss:(PHPickerViewController *)picker\r\n{\r\n [self sendPickerCancel];\r\n}\r\n- (void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray *)results\r\n\r\n{code}\r\n\r\nThe proposed solution was also put in a discussion on GitHub: https://github.com/appcelerator/titanium_mobile/discussions/13046\r\n", "attachment": [ { "id": "67979", "filename": "Screenshot 2021-08-26 delle 12.34.19.mp4", "author": { "name": "ferdi.traversa", "key": "ferdi.traversa", "displayName": "Ferdinando Traversa", "active": true, "timeZone": "Europe/Rome" }, "created": "2021-08-28T21:55:30.000+0000", "size": 7584146, "mimeType": "video/mp4" } ], "flagged": false, "summary": "iOS: openPhotoGallery() does not invoke cancel callback if swiped down", "creator": { "name": "ferdi.traversa", "key": "ferdi.traversa", "displayName": "Ferdinando Traversa", "active": true, "timeZone": "Europe/Rome" }, "subtasks": [], "reporter": { "name": "ferdi.traversa", "key": "ferdi.traversa", "displayName": "Ferdinando Traversa", "active": true, "timeZone": "Europe/Rome" }, "environment": "Titanium SDK 10.0.2.GA, iOS 14.x\r\n\r\nconfirmed on 10.1.0.v20210824071502 by Jason David Miller", "comment": { "comments": [ { "id": "459032", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "so it won't get lost in the other tickets: https://github.com/appcelerator/titanium_mobile/pull/13057\r\n\r\nworks fine in my simulator test", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2021-09-07T13:43:01.000+0000", "updated": "2021-09-07T13:43:01.000+0000" }, { "id": "459086", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "This was backported onto the 10_1_X branch", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2021-10-08T14:09:53.000+0000", "updated": "2021-10-08T14:09:53.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }