Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16479] Android: local HTML-based Google Maps in webview fails to open

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionHold
Resolution Date2014-03-12T20:09:27.000+0000
Affected Version/sRelease 3.2.1
Fix Version/s2014 Sprint 05, 2014 Sprint 05 API
ComponentsAndroid
LabelssupportTeam
ReporterMauro Parra-Miranda
AssigneeHieu Pham
Created2014-02-19T20:15:56.000+0000
Updated2017-07-26T03:24:23.000+0000

Description

Problem Description

When you open a local html file in a webview, it fails (in Android 4.4, using Mobile SDK 3.2.1).

Test Case

App.js:
var win = Ti.UI.createWindow();
var webview = Ti.UI.createWebView({
	url:'index.html',
});
win.add(webview);
win.open();
index.html:
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
var map;
function initialize() {
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644)
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>

Steps to reproduce

1. Create new mobile project (titanium classic) using Mobile SDK 3.2.1 2. Paste the code sample to app.js 3. Paste the index.html contents into a new file index.html in Resources directory 4. Run the app into Nexus 4 or any device with KITKAT 5. See the error messages attached to this bug

Error messages

[INFO] :   TiApplication: (main) [139,532] Titanium Javascript runtime: v8
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[INFO] :   TiAnalyticsDb: (main) [34,34] Upgrading Database from 1 to 4
[WARN] :   V8Object: Runtime disposed, cannot set property 'userAgent'
[INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 11.794MB for 2731536-byte allocation
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.negoapps.mapv3.Mapv3Activity@423e1c88
[INFO] :   chromium: [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
[INFO] :   BrowserProcessMain: Initializing chromium process, renderers=0
[WARN] :   chromium: [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
[INFO] :   I/Adreno-EGL: <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
[INFO] :   Choreographer: Skipped 221 frames!  The application may be doing too much work on its main thread.
[WARN] :   AwContents: nativeOnDraw failed; clearing to background color.
[INFO] :   chromium: [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
[INFO] :   chromium: [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
[ERROR] :  qdutils: FBIOGET_FSCREENINFO failed
[INFO] :   chromium: [INFO:simple_index_file.cc(397)] Simple Cache Index is being restored from disk.
[INFO] :   TiAnalyticsSvc: (Thread-1940) [36578,36578] Analytics Service Started
[INFO] :   TiAnalyticsSvc: (Thread-1940) [1604,38182] Stopping Analytics Service

Extra info

- If you run the webview with google.com it will work just fine, it's not a general issue. - If you want the original html file, you can locate it here: https://developers.google.com/maps/documentation/javascript/examples/map-simple

Q&A Question

http://developer.appcelerator.com/question/162782/google-maps-v3-on-android-44--just-blank

Comments

  1. Vishal Duggal 2014-03-12

    In API 4.4 Android introduced a new version webview based on Chromium. http://developer.android.com/guide/webapps/migrating.html There are some assumptions made on the EGL context in Chromium https://chromium.googlesource.com/chromium/src/gpu/+/cd1cd1e0196f74b9bec50d1a65615db207a8e40d/command_buffer/service/async_pixel_transfer_manager_android.cc We actually turned off hardware acceleration on WebView as part of TIMOB-16358 but that does not seem to be working. The only reliable workaround I have found in Titanium is to set a borderRadius > 0 which adds a borderView with layer type software and turn off hardware acceleration on the WebView. Going to mark this as hold. The workaround is shown below and work on 3.2.1.GA, 3.2.2.GA and the current master branch
       var webview = Ti.UI.createWebView({
           url:'index.html',
           borderRadius:1
       });
       
  2. Hieu Pham 2014-03-12

    This works for me with Nexus 4 (4.4) running on 3.2.1.GA and current master. I did notice an odd error though, the map didn't show when I enable Soasta (com.soasta.touchtest). I get the following error: [ERROR] : dalvikvm: Could not find class 'com.google.android.maps.MapView', referenced from method com.soasta.android.touchtest.recording.TTRecorder.recordSetMapRegion
  3. roel 2014-03-13

    Workaround works (tested on Nexus 4.4 / 3.2.1GA). Thank you.
  4. Ingo Muschenetz 2014-07-09

    [~vduggal] Better workaround: https://github.com/mpociot/TiWebviewFragment
  5. Farouk Mokrani 2014-10-07

    Workaround not worked for me i have AwContents: nativeOnDraw failed; clearing to background color. :(
  6. Be Rushton 2014-11-18

    Spent a day trying to debug this issue, before finally finding this workaround. This needs to be fixed ASAP or at least adding the workaround to the docs while it is on hold.

JSON Source