[TIMOB-23125] Windows: getting photo from gallery fails
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-06-28T03:45:07.000+0000 |
| Affected Version/s | Release 5.2.1 |
| Fix Version/s | Release 5.4.0 |
| Components | Windows |
| Labels | gallery, image, media, qe-5.4.0 |
| Reporter | Zakhar Zhuravlev |
| Assignee | Kota Iguchi |
| Created | 2016-03-24T14:24:04.000+0000 |
| Updated | 2016-06-28T17:08:07.000+0000 |
Description
It's affected 5.2.0
Error code: -1;
Error message: 'Failed to load content from file'
*index.js:*
{noformat}
function onTest() {
Titanium.Media.openPhotoGallery({
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: function(e) {
$.imageView.image = e.media;
},
error: function(error) {
Titanium.UI.createAlertDialog({
title: error.code,
message: error.error,
ok: 'ok'
}).show();
}
});
}
$.win.open();
*index.xml:*
{noformat}
There are two issues related to this. One is you needed to configure
picturesLibrarycapability intiapp.xmlto enable permission to access Windows photo library. The other issue is TIMOB-23115, because of thatImageViewdoesn't acceptBlob. So this issue actually depends on TIMOB-23115. Also we'll need to update the document so we can find appropriate configuration easily.<windows> <manifest> <Capabilities> <Capability Name="internetClient" /> <!-- in case you need Internet connection --> <Capability Name="picturesLibrary" /><!-- This line is required to request access to the photo library --> </Capabilities> </manifest> </windows>Confirmed that latest CI build (5.4.0.v20160331110910) fixes the issue. You can checkout latest build via
ti sdk install -b master -d. Note that you'll need to setpicturesLibraryto yourtiapp.xmlto get access to Windows pictures library like blow.<windows> <manifest> <Capabilities> <Capability Name="internetClient" /> <!-- in case you need Internet connection --> <Capability Name="picturesLibrary" /><!-- This line is required to request access to the photo library --> </Capabilities> </manifest> </windows>I am still able to reproduce this issue using: *Device:* Windows Phone 10.0 *Node.js Version:* 4.4.4 *npm Version:* 4.2.7-2 *Titanium SDK:* 5.4.0.v20160608165242 *Appcelerator CLI Version:* 5.4.0-15 *Appcelerator Studio:* 4.6.0.201605201934 I have added the code below the the TiApp and used the demo code in the comments above:
*Reopening ticket*<windows> <manifest> <Capabilities> <Capability Name="internetClient"/> <!-- in case you need Internet connection --> <Capability Name="picturesLibrary"/> <!-- This line is required to request access to the photo library --> </Capabilities> </manifest> </windows>Turns out it's a regression. 5_4_X: https://github.com/appcelerator/titanium_mobile_windows/pull/742 master: https://github.com/appcelerator/titanium_mobile_windows/pull/743
Sounds like Ewan was able to confirm the fix, so I merged the fixes to 5_4_X and master.
I am still able to reproduce this issue application crashes or just shows a black screen using: *Device:* Windows Phone 10.0, 8.1 *Node.js Version:* 4.4.4 *npm Version:* 4.2.7-2 *Titanium SDK:* 5.4.0.v20160627120037 *Appcelerator CLI Version:* 5.4.0-18 *Appcelerator Studio:* 4.7.0.201606150733 *App.js*
*Added to the Tiapp.xml*var window = Ti.UI.createWindow({ exitOnClose: true, }); var viewParent = Ti.UI.createView({ width: '60%', height: '41%', top: '1%' }); var imageTaken = Ti.UI.createImageView({ width: Ti.UI.FILL, height: Ti.UI.FILL, }); var cameraImage = Ti.UI.createButton({ title: "Choose Photos", bottom: '0%', height: '20%', font: { fontSize: 15, fontWeight: "bold" }, width: Ti.UI.FILL, }); viewParent.add(imageTaken); viewParent.add(cameraImage); window.add(viewParent); cameraImage.addEventListener('click', function (e) { Ti.Media.openPhotoGallery({ autoHide: true, mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO], success: function (e) { if (e.mediaType === Ti.Media.MEDIA_TYPE_PHOTO) { imageTaken.image = e.media; Ti.API.info(JSON.stringify(e)); Ti.API.info(imageTaken.image); } }, cancel: function () { }, error: function (err) { Ti.API.error(err); } }); }); window.open();*Reopening*<windows> <manifest> <Capabilities> <Capability Name="internetClient"/> <!-- in case you need Internet connection --> <Capability Name="picturesLibrary"/> <!-- This line is required to request access to the photo library --> </Capabilities> </manifest> </windows>[~jlongton] I was able to reproduce the crash, and it turns out it was because of
JSON.stringifyagainstBlob. When I removeJSON.stringifyfromsuccesscallback, it went through well for me. Can you try following?So if that's the case, it is because ofsuccess: function (e) { if (e.mediaType === Ti.Media.MEDIA_TYPE_PHOTO) { imageTaken.image = e.media; } },Blob, not because ofTi.Media.openPhotoGallery. I would resolve this ticket, and create new ticket for Blob: TIMOB-23568Verified as fixed. Tested on: Microsoft Lumia 640 (8.1) Microsoft Lumia 640 (10) Windows 10 Pro Studio: 4.7.0.201606150733 Ti SDK: 5.4.0.v20160627224205 Appc NPM: 4.2.7-2 App CLI: 5.4.0-20 Node v4.4.4 *Closing Ticket.*