Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24270] iOS 10.2: Ti.Media.openPhotoGallery returns empty media property

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDone
Resolution Date2017-01-24T09:59:26.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sn/a
ComponentsiOS
Labelslook1
Reportertom quas
AssigneeVijay Singh
Created2017-01-03T18:48:16.000+0000
Updated2018-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() { }
    });

Comments

  1. Hans Knöchel 2017-01-03

    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:
       var 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();
       
    *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 in adjustRotation (Ti.Utils.m}} from return [[imageCopy retain] autorelease]; to return 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.
  2. Hans Knöchel 2017-01-03

    PR: https://github.com/appcelerator/titanium_mobile/pull/8727
  3. tom quas 2017-01-04

    thanks for the quick fix. i came from 5.5.1.GA and saw this issue.
  4. tom quas 2017-01-04

    i added to tiapp.xml: true true but can not confirm that it fixes this issue with 6.0.1.GA.
  5. Hans Knöchel 2017-01-04

    [~tomquas] Did you have the jscore flag in there before? Does it change something to remove it?
  6. tom quas 2017-01-04

    jscore was not in the config when i originally posted this issue. i removed jscore, left true but still am seeing this issue on 6.0.1.GA.
  7. Hans Knöchel 2017-01-04

    The main-thread flag should be added like this (not in the section):
       <property name="run-on-main-thread" type="bool">true</property>
       
    If possible, paste your (anonymized) tiapp.xml contents, thx! *EDIT*: And if possible, also upload the contents of this following file:
       ~/Library/Application Support/Titanium/mobilesdk/osx/6.0.1.GA/iphone/Classes/MediaModule.m
       
  8. Hans Knöchel 2017-01-04

    [~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>
  9. tom quas 2017-01-04

    @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...
  10. tom quas 2017-01-04

    tiapp.xml and MediaModule.m are available here: https://gist.github.com/tomquas/71c476c2d394f4fb93f963685d235e02
  11. tom quas 2017-01-09

    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.
  12. Hans Knöchel 2017-01-18

    Linking the test-case from TIMOB-24323 here as well:
        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();
        
    Thanks for testing the prerelease verison so early guys! That really helps us tremendously to fix issues before GA!
  13. Vijay Singh 2017-01-24

    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 .
  14. Hans Knöchel 2017-01-24

    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.
  15. Pietro Granati 2017-06-28

    Is this fixed? because in 6.1.1 GA I have the same problem
  16. Eric Merriman 2018-08-06

    Closed as completed. If this is in error, please reopen.

JSON Source