Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6658] Android: imageView.toBlob() returns null

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2021-01-14T16:02:43.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterPatrick Reichardt
AssigneeRene Pot
Created2020-12-29T14:57:33.000+0000
Updated2021-01-15T08:37:30.000+0000

Description

Affected Version: * SDK 9.3.0.GA What is expected: * Image (app/assets/150.png) is displayed on screen for iOS and Android * Ti.UI.createImageView().toBlob() returns valid object for iOS and Android What happens: * Image is displayed on iOS and Ti.UI.createImageView().toBlob() returns valid object * Image is displayed on Android but Ti.UI.createImageView().toBlob() returns NULL Android Emulator used to reproduce issue: * Category: Tablet * Screen: 10.5 inch * Resolution: 1080x1920 * Density: hdpi Android-Logs SDK 9.3.0.GA
[INFO]  ImageBlob 1.0 (Powered by Titanium 9.3.0.7bbfd7f849)
[ERROR] imageBlob is null - try .toImage()
[ERROR] imageBlob is still null
[DEBUG] imageView.rect = {"width":0,"x":0,"y":0,"absoluteX":0,"absoluteY":0,"height":0}
Android-Logs SDK 9.2.2.GA
[INFO]  ImageBlob 1.0 (Powered by Titanium 9.2.2.ec614f7881)
[INFO]  imageBlob.height = 150, imageBlob.width = 150
[DEBUG] imageView.rect = {"width":0,"x":0,"y":0,"absoluteX":0,"absoluteY":0,"height":0}

Attachments

FileDateSize
ImageBlob.zip2020-12-29T14:56:57.000+00005358495

Comments

  1. VDLP 2021-01-14

    Any updates on this? Running into the same issue after upgrading to 9.3.0.GA. .toBlob does work on iOS.
  2. Rene Pot 2021-01-14

    Hi, thanks for reporting! This is an async/sync issue. You're expecting in your code the image to be loaded right after creating the ImageView, which is in this situation not the case. In order for your code to work is to block the main thread while the image is loaded, which obviously is not something we would want. What I would recommend is listening for the [load event](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ImageView-event-load) on the ImageView, and do your image handling code there, instead of straight away. This event fires after any image is asynchronously loaded either local or remote image.
  3. VDLP 2021-01-15

    If the ImageView behaved asynchronously in the past that would seem logical. But this isn't the case. A breaking change was introduced between 9.2.2.GA and 9.3.0.GA. This breaking change has not been mentioned anywhere in the changelogs and thus creates an awkward situation when upgrading apps. I would expect minor and patch updates not to break the way existing code behaves. If it does however, I would expect it to be mentioned clearly in the changelogs. I just confirmed that on 9.2.2.GA calling imageView.toBlob(); after creating the imageview does work synchronously. It would be best to revert the breaking change or at least update the changelogs.

JSON Source