[TIMOB-24270] iOS 10.2: Ti.Media.openPhotoGallery returns empty media property
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Done |
| Resolution Date | 2017-01-24T09:59:26.000+0000 |
| Affected Version/s | Release 6.1.0 |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | look1 |
| Reporter | tom quas |
| Assignee | Vijay Singh |
| Created | 2017-01-03T18:48:16.000+0000 |
| Updated | 2018-08-06T17:34:44.000+0000 |
Description
the code snippet below opens the album, but logs the following when run in simulator:
_[WARN] {"success":true,"mediaType":"public.image","code":0,"source":{},"type":"success","media":{}}_
after picking a photo i'd expect media to actually contain data. at least that was how it worked pre-6.0.1.GA.
Ti.Media.openPhotoGallery({
allowEditing:false,
showControls:true,
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: function(e) {
log.warn(JSON.stringify(e));
change_profile_pic(photo_index, e.media, win);
},
cancel: function() { },
error: function() { }
});
Thanks for the report! So this worked in 6.0.0.GA? Are you very sure? Also I knoticed that it's only occurring when you don't run with main-thread enabled. Using it fixes the issue. We'll still investigate it, but need as many infos as possible. Test-Case:
*EDIT*: I am able to reproduce it with 6.1.0 (master), but not with 6.0.1.GA and 5.5.1.GA. The issue is caused by TIMOB-24206, which is also only in master, so 6.0.X cannot be affected. It can be fixed by replacing line invar win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var btn = Ti.UI.createButton({ title: 'Trigger', top: 40 }); var img = Ti.UI.createImageView({ width: 300 }); win.add(img); btn.addEventListener('click', function() { Ti.Media.openPhotoGallery({ allowEditing:false, showControls:true, mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO], success: function(e) { img.setImage(e.media); }, cancel: function() { }, error: function() { } }); }); win.add(btn); win.open();adjustRotation(Ti.Utils.m}} fromreturn [[imageCopy retain] autorelease];toreturn imageCopy;. I made the change between other changes, so probably not checked all use-cases. But anyway, this is all related to 6.1.0, 6.0.1.GA should work properly.PR: https://github.com/appcelerator/titanium_mobile/pull/8727
thanks for the quick fix. i came from 5.5.1.GA and saw this issue.
i added to tiapp.xml:
[~tomquas] Did you have the jscore flag in there before? Does it change something to remove it?
jscore was not in the config when i originally posted this issue. i removed jscore, left
The main-thread flag should be added like this (not in the
If possible, paste your (anonymized) tiapp.xml contents, thx! *EDIT*: And if possible, also upload the contents of this following file:[~htbryant] Can you do a test with your (great) matrices? We'd need a comparison between toggling the following things: - 6.0.1.GA and 6.1.0 (master) -
<property name="run-on-main-thread" type="bool">true/false</property>-<use-jscore-framework>true/false</use-jscore-framework>@hans i set the property which, btw, opposes instructions available here: http://docs.appcelerator.com/platform/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference-section-src-29004921_tiapp.xmlandtimodule.xmlReference-run-on-main-thread still an issue on 6.0.1.GA, w/ or w/o jscore...
tiapp.xml and MediaModule.m are available here: https://gist.github.com/tomquas/71c476c2d394f4fb93f963685d235e02
oops, several things left my dev sandbox in a rotten state. i can confirm that 6.0.1.GA w/o jscore works as expected. i could not make the app work using 6.1.0 at its current state, so no results here. what puzzles me is why the log output does not clearly state that a photo has been selected and its path available. i apologize for causing confusion.
Linking the test-case from TIMOB-24323 here as well:
Thanks for testing the prerelease verison so early guys! That really helps us tremendously to fix issues before GA!var win = Ti.UI.createWindow({ title: 'test', backgroundColor: '#fff' }); // This example is only able to capture video on the iOS platform. // To capture video on the Android platform, see the Android Capture Video Example below. function showCamera() { Titanium.Media.showCamera({ success: function(event) { console.log(event.media.width, event.media.height); // called when media returned from the camera Ti.API.debug('Our type was: ' + event.mediaType); if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { var imageView = Ti.UI.createImageView({ width: win.width, height: win.height, image: event.media }); win.add(imageView); } else { alert("got the wrong type back =" + event.mediaType); } }, cancel: function() { // called when user cancels taking a picture }, error: function(error) { // called when there's an error var a = Titanium.UI.createAlertDialog({ title: 'Camera' }); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Please run this test on device'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, // saveToPhotoGallery:true, // allowEditing and mediaTypes are iOS-only settings allowEditing: false, mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO] }); } win.addEventListener('open', function() { Titanium.Media.requestCameraPermissions(function(e) { if (e.success) { showCamera(); } else { Ti.API.error(e); } }); }) win.open();PR: https://github.com/appcelerator/titanium_mobile/pull/8783 This issue is side effect of TIMOB-24206 . The leak issue, TIMOB-24206, is only with jscore and in all other cases its working fine. So as discuss with [~hansknoechel] , reverting changes of TIMOB-24206. We will find proper solution for same .
Reverted the fix from TIMOB-24206, so this one does not happen anymore. We'll need to find a more solid solution for the other one.
Is this fixed? because in 6.1.1 GA I have the same problem
Closed as completed. If this is in error, please reopen.