Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24169] iOS: backgroundTopCap + backgroundLeftCap broken on Ti.UI.Button in 6.0.0.GA (Regression)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-11-30T10:34:47.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.0.1
ComponentsiOS
Labelsbackgroundtopcap, button, ios, regression
ReporterGertjan Smits
AssigneeVijay Singh
Created2016-11-23T18:59:42.000+0000
Updated2016-12-16T16:14:30.000+0000

Description

I just upgraded to Ti SDK *6.0.0.GA* coming from 5.4.0.GA and I noticed that using backgroundLeftCap and backgroundTopCap are broken on Ti.UI.Button but works fine on Ti.UI.View. It used to work both in 5.4.0. The issue is easy to reproduce with the following code, I supplied a background png in the attachment.
var win = Ti.UI.createWindow();
var container = Ti.UI.createView({
	top:100,
	layout:'vertical',
	width:450
});

var button = Ti.UI.createButton({
	top:0,
	backgroundImage:'button_background.png',
	backgroundTopCap:50,
	backgroundLeftCap:50,
	width:450,
	height:100
});

var view = Ti.UI.createView({
	top:50,
	backgroundImage:'button_background.png',
	backgroundTopCap:50,
	backgroundLeftCap:50,
	width:450,
	height:100
});

container.add(button);
container.add(view);
win.add(container);
win.open();

Attachments

FileDateSize
button_background.png2016-11-23T18:58:09.000+00004182
Simulator Screen Shot 23 Nov 2016, 20.35.09.png2016-11-23T19:35:19.000+000034995

Comments

  1. Hans Knöchel 2016-11-23

    Hey there, iOS or Android? We will then test if it's 5.5.x or 6.x that caused it. Thx! *EDIT*: I was able to reproduce it on iOS, and it works in 5.5.1, so it's a 6.0.0 regression. Moving for further investigation.
  2. Gertjan Smits 2016-11-23

    Hi, as far as I know these properties are only supported on iOS :) If not, then I mean iOS.
  3. Hans Knöchel 2016-11-23

    [~vijaysingh] This is a regression caused by [this change]https://github.com/appcelerator/titanium_mobile/commit/7ee97f46b21ab05434d3c588e1ae24450a6eb5f0] in TIMOB-23666. I noticed three things:

    We need to restore the [self loadImage:value], since it handles much more than just loading (e.g. scaling and stretching)

    We still need to support remote images, for example by something like this:

           if (!backgroundImageCache) {
               NSURL *bgURL = [TiUtils toURL:value proxy:[self proxy]];
               backgroundImageCache = [[ImageLoader sharedLoader] loadImmediateImage:bgURL];
               if (backgroundImageCache == nil) {
                   backgroundImageCache = [[[ImageLoader sharedLoader] loadRemote:bgURL] retain];
               } else {
                   [backgroundImageCache retain];
               }
           }
       

    The same applies for setBackgroundSelectedImage_, setBackgroundDisabledImage_ and setBackgroundFocusedImage_ which currently don't support remote images when they are not in the cache already.

    So we would need to come up with a solution that covers all those use-cases together.
  4. Vijay Singh 2016-11-25

    This change will affect background image setting for TIUIiOSToolbar, TIUISearchbar, TIUITabGroup, TiUITextField and TIUIiOSStepper and TIUIButton's all state(selected , highlighted etc). If images are not cached, it will download image from remote . PR : https://github.com/appcelerator/titanium_mobile/pull/8635 In above solution [TiUtils loadBackgroundImage:image forProxy:[self proxy]]; already return image but we are not using it for capping . Rather we use [[ImageLoader sharedLoader] loadImmediateStretchableImage:url withLeftCap:leftCap topCap:topCap]; [ImageCacheEntry stretchableImage] which internally call for capped image which again get image from cache. Ideal solution is, -(UIImage *)stretchableImage should be available as extension of UIImage. We should use image from [TiUtils loadBackgroundImage:image forProxy:[self proxy]]; and call -[UIImage stretchableImage] ; [~hansknoechel] Let me know your comment .
  5. Gertjan Smits 2016-11-29

    Can an estimate be given when this release will be done? We're getting close to our deadline and I have to make a decision if I will use 6.0.0.GA, because without this, I simply can not.
  6. Hans Knöchel 2016-11-29

    [~gertjans] This ticket is in review for 6.0.1 which will be released in early December. In the meantime, you could either patch your SDK with the provided commit or rollback [this commit](https://github.com/appcelerator/titanium_mobile/commit/7ee97f46b21ab05434d3c588e1ae24450a6eb5f0).
  7. Vijay Singh 2016-11-30

    Reverted changes of TIMOB-23666 for 6_0_x . PR(6_0_x) : https://github.com/appcelerator/titanium_mobile/pull/8643
  8. Hans Knöchel 2016-11-30

    Fixed by reverting the remote-images changes from TIMOB-23666 for now.
  9. Abir Mukherjee 2016-12-01

    Verified with this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.0.1.v20161130023500 Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM Device: iOS 10.0 I was able to reproduce the issue with SDK 6.0.0 GA. I tried the demo code with SDK 5.5.1 GA and did not see the issue; verifying that the regression is with 6.0.0 GA. I then tried the demo code on both Simulator and Device and verified that the bug is fixed with SDK 6.0.1.
  10. Gertjan Smits 2016-12-16

    When does early december end ;) ?
  11. Hans Knöchel 2016-12-16

    [~gertjans] Xcode 8.2 came along earlier than expected :-) A release before Christmas is still scheduled!

JSON Source