incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filip Maj (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-569) Script tags embedded in body content referencing packaged .js file do not load on Android 4.x
Date Thu, 10 May 2012 00:13:44 GMT

     [ https://issues.apache.org/jira/browse/CB-569?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Filip Maj updated CB-569:
-------------------------

         Priority: Minor  (was: Major)
      Environment: 
Can reproduce with Cordova 1.6.1 and 1.7.0 on the following devices:

 - ASUS Transformer TF101 (Android 3.2)
 - HTC Desire Z (Android 2.2.1)
 - Samsung Galaxy Nexus (4.0.2)
 - Emulator (4.0.3)

Cannot reproduce on:
 - Emulator running 2.3.3

  was:
*OS* 
Fedora 16 (kernel 3.3.2-1.fc16.i686.PAE)
*Software*
Eclipse (Version: Indigo Service Release 1, Build id: 20110916-0149)
Eclipse plugins: Android Development Tools 17.0.0v201203161636-291853, PhonegapForAndroid
1.2.9.201204181638, ... (i'll provide full list if necessary)
*Libs*
Cordova 1.6.1
jQuery 1.7.2
jQuery mobile 1.1.0
*Devices*
ASUS Transformer TF101 (Android 3.2)
HTC Desire Z (Android 2.2.1)

    Fix Version/s:     (was: 1.8.0)
          Summary: Script tags embedded in body content referencing packaged .js file do not
load on Android 4.x  (was: Multiscreen jquerymobile application doesn't work on Asus Transformer
TF101)

I tried your jQM example with a Galaxy Nexus (failed) and a Gingerbread emulator running 2.3.3
(passes).

With a clean & empty cordova project, when I dynamically create and add script tags to
the {{<head>}}, it works fine on both a Gingerbread emulator and ICS device. Code:

{code:javascript}
      function loadContent() {
        var s = document.createElement('script');
        s.src = 'external.js';
        s.type = 'text/javascript';
        document.getElementsByTagName('head')[0].appendChild(s);
      }
{code}

Then I tried XHR'ing to external.js (to sort of mimic how jQuery mobile functions in this
case), and {{eval}}'ing the contents. That worked on both Gingerbread and ICS again.

Rather, it seems like script tags that are embedded inside HTML content, which gets dumped
into the document, are not parsed properly by Android 4.x.

Unfortunately this is a very specific case and your issue is rather with a (likely) bug in
the Android WebView in Android 4.x. The mechanism with which jQuery mobile injects content,
and thus your script tags, exposes this issue. Perhaps jQM should have a parser for scripts
tag built-into the content switcher and dump them into the document via the method above.
Or this bug should be identified and brought to Google's attention.

I've identified a couple of workarounds in this issue:
 # You could embed the content of your local .js files within the <script> tags that
are inside your jQM app's HTML pages. Since Cordova requires a compile step, you could integrate
a find/replace of script tags with src="local content" into the same script tags with the
content in-line at compile time, as an additional build step, for example.
 # If jQM offers event hooks for page switches, you could integrate some kind of page onload
JavaScript handler that injects the script tags needed for those pages with my code snippet
above.

I've reduced the severity of the bug and removed any fix version for now. I don't know what
we can do to fix this. I'm now digging into how jQuery Mobile loads the content to try to
isolate it to a specific set of steps.
                
> Script tags embedded in body content referencing packaged .js file do not load on Android
4.x
> ---------------------------------------------------------------------------------------------
>
>                 Key: CB-569
>                 URL: https://issues.apache.org/jira/browse/CB-569
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 1.6.1, 1.7.0
>         Environment: Can reproduce with Cordova 1.6.1 and 1.7.0 on the following devices:
>  - ASUS Transformer TF101 (Android 3.2)
>  - HTC Desire Z (Android 2.2.1)
>  - Samsung Galaxy Nexus (4.0.2)
>  - Emulator (4.0.3)
> Cannot reproduce on:
>  - Emulator running 2.3.3
>            Reporter: Eugene Grybinnyk
>            Assignee: Filip Maj
>            Priority: Minor
>
> I've created a simple jqm app with 2 screens - when you click any on the first screen
(index.html) you will follow to the second screen (second_screen.html). Second screen is including
some js code in it's body as external file (with a simple alert inside).
> So an *Expected Result* - I click on link and see alert message
> When I deploy it on my local apache httpd server - it's working fine on desktop browsers,
and native mobile browsers on ASUS Transformer TF101 (ASUS) and HTC Desire Z (HTC).
> Then, I create a Phonegap (Cordova) project on Eclipse using PhonegapForAndroid plugin
(target api - 7, android 2.1), export signed apk and install in on ASUS and HTC.
> And *Actual Result* - apk installed on HTC - works like in a browser, but the same apk
installed on ASUS - doesn't work properly - I click on a link and don't see alert.
> * I tried to reassemble the apk specifying target api - 13 (android 3.2) but it had no
effect for ASUS device.
> * I tried to run the problematic apk-s on android virtual device (api 13, android 3.2)
and it works fine (both apk-s, with 7 and 13 target api-s).
> PS /
>  Links:
> HTML/CSS/JS bundle http://dl.dropbox.com/u/33175266/external_js_test_jqm.zip
> Eclipse project (target api - 7) http://dl.dropbox.com/u/33175266/external_js_test_jqm_api7.zip
> Eclipse project (target api - 13) http://dl.dropbox.com/u/33175266/external_js_test_jqm_api13.zip
> Signed apk (target api - 7) http://dl.dropbox.com/u/33175266/external_js_test_jqm_api7_signed.apk
> Signed apk (target api - 13) http://dl.dropbox.com/u/33175266/external_js_test_jqm_api13_signed.apk
> PSS /
>  There are two links in the project, first is handled with jqm implicitly and second
is calling jqm function $.mobile.changePage via handler, attached with jQuery.live on vclick
event. Both of them are working well on browsers and HTC and are not working on ASUS. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message