Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14533] Android: Picture capture returns last photo in gallery, not the one just captured

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-05-28T16:05:36.000+0000
Affected Version/sRelease 3.1.0
Fix Version/s2013 Sprint 24, 2013 Sprint 24 API, Release 3.2.0
ComponentsAndroid
Labelsandroid, android-4.0, camera, module_media, qe-testadded, sony, triage, xperia
ReporterArnaud Besnier
AssigneePing Wang
Created2013-07-02T09:19:16.000+0000
Updated2014-05-28T16:07:29.000+0000

Description

We have 4 Sony Ericsson devices here: - Xperia S (LT26i) on Android 4.1.2 - Xperia Arc (LT15i) on Android 2.3.3 - Xperia Arc S (LT18i) on Android 2.3.4 - Xperia U (ST25i) on Android 2.3.7 Everything is ok, except for the Xperia S on Android 4.1.2. After a camera snapshot, the picture returned is not the one just captured, but the last in the gallery... That is a really bad bug for data privacy. I found a solution to fix this, here is the pull request I made: https://github.com/appcelerator/titanium_mobile/pull/4432 With this fix, the camera works properly on all our devices (we also have Samsung, LG, Motorola and HTC ones)

Comments

  1. Ygor Lemos 2013-09-27

    I can confirm this is affecting a lot of users using Sony Ericsson devices. (still collecting data to see if the same problem occurs to users of other phones...)
  2. Ygor Lemos 2013-09-27

    Tested on 3.1.2.GA and this still happens!
  3. Ygor Lemos 2013-09-27

    Also happening on Sony Ericsson Xperia L. Some users are also reporting similar problems with *Motorola* Razr D3 XT920 and XT919 indicating that this bug may not be related only to Sony Ericsson devices.
  4. Olga Romero 2013-10-01

    I tested KS (3.1.4) camera on XPERIA 2.3.7 and Nexus4 Android version 4.3 with Appcelerator Studio, build: 3.1.3.201309132456 Titanium SDK, build: 3.1.4.v20130927154557 and cannot reproduce the issue. We will continue to investigate.
  5. Ygor Lemos 2013-10-02

    This only happens on selected devices.
  6. Ygor Lemos 2013-10-12

    Reported by many users (30+) using Sony Xperia SP...
  7. Ingo Muschenetz 2013-10-14

    [~ygbr] What would be the difference between the Sony Xperia we tried, and the one you are reporting it on? We need to find some device to reproduce the issue.
  8. Ygor Lemos 2013-10-14

  9. Ygor Lemos 2013-10-18

    Just got a brand new Xperia S LT26i yesterday for solving this. I have tested my application which works fine on all other droids and it worked normally on the Xperia S as it came from factory (Android 4.0.4). Then I observed it had some "updates" so I have updated it from Android 4.0.4 to Android 4.1.2 and then the error could be reproduced. So... if you guys have any of those Xperias, update it to 4.1.2 and the error instantly pops. All the pics I took, returned random gallery images instead of the pic I have just taken. Guess it has to do with Sony custom camera app. I will test the solution using Intents today as post back.
  10. Ygor Lemos 2013-10-21

    Also I have notice that after updating to 4.1.2 (Sony Build: 6.2.B.0.200) the showCamera() shows a dialog asking whether you want to use the Camera or Photo Effect (this dialog didn't exist on 4.0.4 where the camera worked properly). I have of course selected the camera option for taking the picture but the returned picture was always a random picture from the gallery.
  11. Ygor Lemos 2013-10-21

    2 more things: 1 - I have updated the phone to the very latest build available by Sony ( 6.2.B.1.96) the problem STILL PERSISTS but the dialog seems to have vanished. 2 - I have tried the solution based on android.media.action.IMAGE_CAPTURE Intent but on the Xperia, startActivityForResult() never calls the callback function after you take the picture no matter what you do. Really awkward. Any ideas on alternatives ways to call this intent and get the result image?
  12. Ygor Lemos 2013-10-21

    As a last attempt, I have built Titanium from source (targeted on 3_1_3_GA tag) and applied PR 4332 manually (https://github.com/appcelerator/titanium_mobile/pull/4432) as mentioned on the issue desc. I can attest that this PR WORKS. Tested on 3.1.3.GA + PR4332 built on mac. Device: Sony Xperia S LT26i (Android 4.1.2 - Build: 6.2.B.1.96) I have also asked for some users to test on their devices and I have received 3 positive feedbacks. Please apply this PR to master or use it as a baseline for fixing this issue for Xperia devices on Android 4.1.2+
  13. Ingo Muschenetz 2013-10-28

    [~ygbr] The thing that concerns me about that PR is that it just adds an if statement specific to one manufacturer of devices. It seems like a relatively fragile fix. Thoughts?
  14. Ygor Lemos 2013-10-28

    Hi Ingo, Indeed it is very fragile. As arnauld commented on the PR itself (https://github.com/appcelerator/titanium_mobile/pull/4432#issuecomment-26782562) it only solves the problem for a few devices. In my case it has solved the problem for both devices that I bought for this specific bug. I think that maybe this whole if block needs some thought from the Ti Engineers that wrote it since this clearly starts the problem for several devices.
        if (c == null && !Build.MANUFACTURER.equals("Sony Ericsson")) {
            c = activity.getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, projection, null, null,Images.ImageColumns.DATE_TAKEN);
            isDataValid = false;
        }
        
    I've tried the Intent "solution" but although it opens the camera, the callback on startActivityForResult is never called on those devices which is very strange. On the Xperia S (LT26i) device I have managed to reproduce this issue every time, even after factory resetting the device multiple times. Do you guys have one of those lying around on Appcelerator? I saw some camera-related garbage on logcat (low level C calls). Perhaps related to Sony camera customizations that are causing those problems.
  15. Eric Merriman 2013-10-31

    [~ygbr] The QE team tried to reproduce this with our closest device, an Xperia U with 2.3.6. We were unable to repro trying a few scenarios: * Kitchensink * Sample code from TIMOB-12848 * Sample code as above but with "save to gallery" true * Empty Gallery with above code * Populated gallery with above code Do you have code that reliably fails that we can use? It would help a great deal as we are not clear on the gallery interaction you are using.
  16. Ygor Lemos 2013-11-02

    @Eric you need to test it with 4.1.2 or greater... this does not seen to happen on older Android versions only on new ones. This very code works and reproduces normally on a factory resetted Xperia S LT26i running 4.1.2. Try on Xperia's running the latest version of Android 4.1.x
  17. Ygor Lemos 2013-11-06

    It is important to notice that this issue happens ONLY on Android 4.x and up on select Xperia devices. I haven't been able to reproduce it on older Android versions.
  18. Eric Merriman 2013-11-07

    Hello, We have upgraded our Xperia and are still unable to reproduce. What would be extremely helpful is to get some sample code with the specific workflow that is causing the problem. We've tried a few combinations using the sample code mentioned, but it doesn't seem to occur. Also, does this have any connection with either full or empty galleries? We've tried both.
  19. Eric Merriman 2013-11-12

    Hello all, based on what we can tell, this looks like a 4.1 issue on these particular devices. Our two physical devices are an Xperia Arc S and an Xperia U. The Arc S maximum is 4.0, and the U is also 4.0. Although we updated the Arc S, we are still unable to reproduce. We will see if the new genymotion image reproduces the problem, while we see if we can find an Xperia device that is capable of 4.1+.
  20. Hieu Pham 2013-11-13

    Closing as unable to reproduce until we get a reliable test case.
  21. Arnaud Besnier 2013-11-14

    This is sad. It is an everyday bug on our Android app.
  22. Ygor Lemos 2013-11-14

    You cannot reproduce this because you haven't followed the specs for the bug to happen. You must have a Xperia device in which this occurs like the LT26i You must be on Android 4.1.2 or later as clearly this doesn't happen on older versions Clearly this doesn't reproduce on Xperia U with Android 4.0 I will attach a video showing the behavior with a factory resetted Xperia running the test case
  23. Arnaud Besnier 2013-11-14

    Thank you Ygor!
  24. Ingo Muschenetz 2013-11-15

    We are purchasing an Xperia LT26i. Hopefully this will allow us to reproduce the issue.
  25. Ping Wang 2013-11-21

    PR: https://github.com/appcelerator/titanium_mobile/pull/5002 Test case
        var win = Ti.UI.createWindow({
        	backgroundColor : 'white'
        });
        
        var imageView = Ti.UI.createImageView({
        	width : 400,
        	height : 400
        });
        win.add(imageView);
        
        var button = Ti.UI.createButton({
        	top : 0,
        	title : "open camera"
        });
        
        button.addEventListener("click", function() {
        	Titanium.Media.showCamera({
        
        		success : function(event) {
        			Ti.API.info('Our type was: ' + event.mediaType);
        			if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
        				imageView.image = event.media.imageAsResized(400, 400);
        
        			} else {
        				alert("got the wrong type back =" + event.mediaType);
        			}
        		},
        		cancel : function() {
        			Ti.API.info("***************** cancel");
        		},
        		error : function(error) {
        			Ti.API.info("***************** error");
        		},
        		saveToPhotoGallery : true,
        		mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO]
        	});
        });
        
        win.add(button);
        
        win.open(); 
        
    For FR: 1. Run the above test case on Xperia LT26i(4.1.2). Take a picture and should see the picture showing in the image view. Go to the gallery/album and should see the picture which is just captured. 2. Run the above test case on a variety of devices to make sure it does not break anything.
  26. Samuel Dowse 2013-11-22

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201311211626 Titanium SDK, build: 3.2.0.v20131122125648 CLI: 3.2.0-alpha Android Devices: Xperia S (4.1.2), Galaxy Note II (4.1.2), Xperia Arc S (4.0.4) Using the test case provided I was able to take a picture and have it display the picture I had just taken. Camera functionality seems unaffected on other devices and Android version. All seems to be working as expected. Closing

JSON Source