Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20586] Parity: backgroundColor, backgroundImage, backgroundGradient

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2017-08-15T21:36:13.000+0000
Affected Version/sRelease 5.2.0
Fix Version/sRelease 6.2.0
ComponentsAndroid
Labelsparity
ReporterHieu Pham
AssigneeFrankie Merzadyan
Created2016-03-16T22:26:36.000+0000
Updated2017-08-18T23:59:22.000+0000

Description

Behaviors for backgroundColor, image and gradient are different for Android and iOS. Android: 3 layers with color -> gradient -> image. Everything is bundled up and whatever is on top shows. iOS: prioritize image over gradient over color, ultimately only displays one.

Comments

  1. Farzad Merzadyan 2016-10-11

    [~smohammed] can you verify?
  2. Samir Mohammed 2016-10-11

    [~fmerzadyan] No error occurred with the code above. Mac Version: 10.11.6 Xcode 8.0 Build version 8A218a APPC CLI AND APPC NPM VERSION: {"NPM":"4.2.7","CLI":"5.5.1"} APPC TI CLI VERSION: 5.0.9 APPC ALLOY VERSION: 1.9.2 NODE VERSION: v4.5.0 SELECTED SDK VERSION:Selected :6.0.0.v20161005072811
  3. Farzad Merzadyan 2016-10-19

    I think this *ticket is invalid* because user probably didn't put image file in a common folder such as studio-project-folder/Resources/assets folder which is located on the same level as android/ and iphone/ folders. Therefore the backgroundImage path to image was incorrect for one of the platforms. Use this to test:
       var window = Ti.UI.createWindow(
           { title: 'TIMOB-20586' }
       );
       //backgroundImage:"images/back.jpg" for android.
       //backgroundImage: "back.jpg" for ios.
       //common path is assets/images/back.jpg
       var view = Ti.UI.createView({
           backgroundColor: 'yellow',
           backgroundGradient: {
               type: 'linear',
               startPoint:
               { x: '0%', y: '50%' }
               ,
               endPoint:
               { x: '100%', y: '50%' }
               ,
               colors: [
                   { color: 'red', offset: 0.0}
                   ,
                   { color: 'blue', offset: 0.25 }
                   ,
                   { color: 'red', offset: 1.0 }
               ]
           },
           backgroundImage: 'assets/images/back.jpg'
       });
       window.add(view);
       window.open();
       //
       try {
       	var file = Titanium.Filesystem.getFile("assets/images/back.jpg");
       	console.log("The file assets/images/back.jpg exists: " + file.exists());
       } catch (err) {
       	console.log("The file was not retrieved");
       }
       
    However backgroundImage does not load when using live view in Studio (from frequent file changes) which gives the impression that the layer rendering malfunctioned. However as you can see here in the console log underneath loading up a bitmap image is resource intensive and so OOM happens so backgroundImage is not loaded... {noformat} [WARN] : art: Throwing OutOfMemoryError "Failed to allocate a 14745612 byte allocation with 13655792 free bytes and 13MB until OOM" [DEBUG] : skia: --- decoder->decode returned false [ERROR] : TiUIHelper: (main) [59,746] Unable to load bitmap. Not enough memory: Failed to allocate a 14745612 byte allocation with 13655792 free bytes and 13MB until OOM [DEBUG] : Window: Checkpoint: postWindowCreated() [WARN] : EGL_emulation: eglSurfaceAttrib not implemented [WARN] : OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe99bfc00, error=EGL_SUCCESS [ERROR] : Surface: getSlotFromBufferLocked: unknown buffer: 0xe7fb6a40 [DEBUG] : Window: Window is closed normally. [ERROR] : Surface: getSlotFromBufferLocked: unknown buffer: 0xe7fb8640 [INFO] : APSAnalyticsService: Analytics Service Started [INFO] : APSAnalyticsService: Stopping Analytics Service {noformat}
  4. Chee Kiat Ng 2016-10-20

    Then most likely it's because the unit test was written incorrectly on https://github.com/appcelerator/titanium-mobile-mocha-suite/blob/master/Resources/ti.ui.view.test.js This ticket was raised because of some failing unit tests here. We can fix the unit test here so that it test for parity between android and ios. Check out the FIXME comments, likely 1 of those is related to this ticket. Likely this one. https://github.com/appcelerator/titanium-mobile-mocha-suite/blob/master/Resources/ti.ui.view.test.js#L32 right now that particular test is skipping for all 3 platforms. we want it to work for iOS and android, while skipping windows :)
  5. Frankie Merzadyan 2017-02-28

    titanium-mobile-mocha-suite master: https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/16
  6. Lokesh Choudhary 2017-08-18

    Closing.

JSON Source