Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16840] Android: Webview with '_.template' rendered HTML not displayed

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-04-11T22:37:05.000+0000
Affected Version/sRelease 3.2.3
Fix Version/s2014 Sprint 07, Release 3.2.3, Release 3.3.0
ComponentsAndroid
Labelsmodule_android, qe-3.2.3, qe-testadded, regression
ReporterFederico Casali
AssigneeHieu Pham
Created2014-04-10T00:23:00.000+0000
Updated2014-04-21T18:44:56.000+0000

Description

Problem description

In the Dynamic Styling Alloy sample https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/dynamic_styling , in the 'rawStyle' window, there is a webView whose html content is rendered using the Underscore.js '_.template' utility:
$.styleArray.html = _.template(Alloy.Globals.htmlTemplate, {
	CODE: JSON.stringify(require('alloy/styles/features/rawStyle'), null, '  '),
	BRUSH: 'js'
});
Alloy.Globals.htmlTemplate (in app/alloy.js):
Alloy.Globals.htmlTemplate = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><script type="text/javascript" src="web/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="web/syntaxhighlighter/scripts/shBrushJScript.js"></script><link type="text/css" rel="stylesheet" href="web/syntaxhighlighter/styles/shCoreDefault.css"/><script type="text/javascript">SyntaxHighlighter.all();</script></head><body style="background: white; font-family: Helvetica; "><pre class="brush: <%= BRUSH %>; gutter: false;"><%= CODE %></pre></html>';
If no targetSdkVersion is specified or if a targetSdkVersion specified is greater than 13, running the sample on Android using the latest SDK (3.2.3.v20140403105720), the Webview is not visible. Is correctly visible using 3.2.2.GA on both iOS and Android.

Steps to reproduce

1. Create a new Alloy project and import the Alloy sample code https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/dynamic_styling (or get the attached project) 2. Run on Android and click on 'Raw Style Modules' Result: second webView () is not visible. 3. Edit tiapp.xml, add the following and run on Android:
<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <uses-sdk android:targetSdkVersion="11"/>
        </manifest>
</android>
Result: the webView is now correctly displayed 4. Edit tiapp.xml, add the following and run on Android:
<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <uses-sdk android:targetSdkVersion="19"/>
        </manifest>
</android>
Result: Webview is no longer displayed. 5. Edit tiapp.xml, switch to SDK 3.2.2.GA, use any targetSdkVersion (from 11 to 19) and run on device: Result: webview is always correctly displayed. It seems to be a regression on the SDK (also no changes made on Alloy). Attached screenshots for comparison between a displayed and not-displayed webview.

Note

If using Jake to import the Alloy sample project, it works fine as in this case an Harness template with targetSdkVersion='11' is being used. If using the default new app tiapp.xml file (with no targetSdkVersion being specified in the manifest), the sample webview is not visible.

Attachments

FileDateSize
3.2.2_windows.png2014-04-10T00:23:00.000+0000130762
3.2.X_windows.png2014-04-10T00:23:00.000+000096481
passTestAlloy.zip2014-04-10T22:10:33.000+00005044125

Comments

  1. Tim Poulsen 2014-04-10

    I don't believe this to be an Alloy bug. It is related to the Android SDK version used to build the app. Anything newer than API version 13 exhibits the problem; older Android API levels don't have this issue. My test: 1. Create a new project with the CLI 2. Edit tiapp.xml to set Ti SDK to 3.2.3.Alpha 3. Build via command line to Genymotion emulator (Galaxy Nexus, Android 4.2.2). App exhibits the behavior as described (second webview isn't visible) 4. Modify tiapp.xml, adding the code below. Rinse and repeat using targetSdkVersions from 11 (which is what is set by the Harness Template) through 19. Android SDK versions 11, 12, and 13 -- the app works properly. Any SDK version higher than 13 exhibits the behavior described in the ticket. 5. Modify tiapp.xml setting TiSDK to 3.2.2.GA and targetSdkVersion to 19. The app runs properly.
       <android xmlns:android="http://schemas.android.com/apk/res/android">
          <manifest>
             <uses-sdk android:targetSdkVersion="13"/>
          </manifest>
       </android>
       
       
  2. Hieu Pham 2014-04-11

    master PR: https://github.com/appcelerator/titanium_mobile/pull/5592 3.2.x PR: https://github.com/appcelerator/titanium_mobile/pull/5593
  3. Federico Casali 2014-04-14

    Verified as fixed. TiSDK 3.2.3.v20140411160129 Alloy 1.3.1 Appcelerator Studio 3.2.3.201404111117 Mac OS X and Windows 7 x64 Google Nexus Galaxy 4.3 Closing.
  4. Wilson Luu 2014-04-15

    Closing ticket as per Federico's comment.

JSON Source