[TIMOB-25766] Android: Ti.Utils.base64encode for cannot encode (Image) Ti.Blob anymore. Result = null
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-09T19:53:54.000+0000 |
Affected Version/s | Release 7.0.2 |
Fix Version/s | Release 7.0.2 |
Components | Android |
Labels | regression |
Reporter | Muhammad Ahmed Fahad |
Assignee | Hans Knöchel |
Created | 2018-02-09T09:00:47.000+0000 |
Updated | 2018-02-12T02:25:16.000+0000 |
Description
Ti SDK: 7.0.2.v20180207091331
Device: Samsung Galaxy S8+
Android: 7.0.0
Works fine with Ti SDK 7.0.1.GA
Test Case:
Ti.Media.showCamera({
success:function(event) {
if(event.mediaType === Ti.Media.MEDIA_TYPE_PHOTO) {
var image = event.media;
Ti.API.info(Ti.Utils.base64encode(image).text);
}
},
cancel:function() {
},
error:function(err) {
Ti.API.error(err);
},
mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
});
Expect Output: A random encoded string
Actual output: Uncaught TypeError: Cannot read property 'text' of null
Please try to fix this issue before releasing 7.0.2
[~fahad86] Thanks for the ticket, I'll move this across to TIMOB Able to reproduce this issue using SDK: 7.0.2.v20180207091331 One Plus 3 7.1.1 This does not occur using SDK 7.0.2.v20180207022213 so the cause appears to be TIMOB-25727 Full code include permissions handling
Steps to reproduce
Build to Android
Tap screen
Take photo
Actual
Code throws errorExpected
Logging like the belowmaster: https://github.com/appcelerator/titanium_mobile/pull/9813 7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9812
I see what was wrong. The issue was that the image blob's byte array was being transcoded from UTF-8 to UTF-16, which changed the binary before being base64 encoded. The old way of calling TiBlob.toBase64() would have preserved the original bytes.
FR Passed & verified the fix in SDK 7.0.2.v20180209105903. Studio Ver: 5.0.0.201712081732 SDK Ver: 7.0.2.v20180209105903 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.12-3 Appc CLI: 7.0.2-master.8 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 5 --- Android 6.0.1 ⇨ google Nexus 6P --- Android 7.1.2
Master FR done & merged.
Verified the fix with SDK 7.1.0.v20180209115809. Closing. Studio Ver: 5.0.0.201712081732 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.12-3 Appc CLI: 7.0.2-master.8 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 5 --- Android 6.0.1 ⇨ google Nexus 6P --- Android 7.1.2
Thanks all for the quick fix.