Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17139] Android: Ti.UI.WebView.setUserAgent() breaks HTML selection

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2016-04-20T07:51:40.000+0000
Affected Version/sRelease 5.0.2
Fix Version/sn/a
ComponentsAndroid
Labelswebview
ReporterMatthew Spivey
AssigneeSrikanth Sombhatla
Created2014-05-13T16:14:38.000+0000
Updated2016-04-20T07:51:40.000+0000

Description

Issue description

The Titanium Android app below sets the user-agent on a WebView, so the web server can differentiate the Android app from the Android browser. When setUserAgent is used, touching an HTML select will no longer open the input on the bottom of the screen.

app.js

var tabGroup = Ti.UI.createTabGroup({ exitOnClose: true });
    var webView = Titanium.UI.createWebView();
    webView.setUrl('select.html');
 
    // removing the setUserAgent fixes the HTML select
    webView.setUserAgent('Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; SAMSUNG-SGH-I747 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30');
 
    var window = Titanium.UI.createWindow();
    window.add(webView);
    var adviceTab = Ti.UI.createTab({
        title : "Title",
        window : window
    });
    window.containingTab = adviceTab;
    tabGroup.addTab(adviceTab);
    tabGroup.open();

select.html

<!DOCTYPE html>
<html>
<head>
<title>Testing options</title>
</head>
<body>
<select>
<option>one</option>
<option>two</option>
<option>three</option>
</select>
</body>
</html>

Stack trace

-- Start application log -----------------------------------------------------
[INFO] :   TiApplication: (main) [1,1] checkpoint, app created.
[INFO] :   TiApplication: (main) [36,37] Titanium 5.0.2 (2015/09/30 12:07 92c2265)
[INFO] :   TiApplication: (main) [18,55] Titanium Javascript runtime: v8
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[WARN] :   V8Object: (KrollRuntimeThread) [387,387] Runtime disposed, cannot set property 'userAgent'
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.appc.test.AndroidserviceActivity@208e5400
[DEBUG] :  OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[DEBUG] :  D/        : HostConnection::get() New Host Connection established 0xb3ecede0, tid 7052
[DEBUG] :  Atlas: Validating map...
[DEBUG] :  libEGL: loaded /system/lib/egl/libEGL_emulation.so
[DEBUG] :  libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
[DEBUG] :  libEGL: loaded /system/lib/egl/libGLESv2_emulation.so
[DEBUG] :  D/        : HostConnection::get() New Host Connection established 0xaec39840, tid 7077
[INFO] :   OpenGLRenderer: Initialized EGL, version 1.4
[DEBUG] :  OpenGLRenderer: Enabling debug mode 0
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xaec35c60, error=EGL_SUCCESS
[TRACE] :  updating tiapp metadata with Appcelerator Platform...
[DEBUG] :  TabGroup: Checkpoint: postTabGroupCreated()
[INFO] :   WebViewFactory: Loading com.android.webview version 39 (eng.buildbot-x86) (code 399997)
[INFO] :   LibraryLoader: Time to load native libraries: 3 ms (timestamps 1967-1970)
[INFO] :   LibraryLoader: Expected native library version number "",actual native library version number ""
[TRACE] :  WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {136e5b52}
[INFO] :   LibraryLoader: Expected native library version number "",actual native library version number ""
[INFO] :   chromium: [INFO:library_loader_hooks.cc(104)] Chromium logging enabled: level = 0, default verbosity = 0
[INFO] :   BrowserStartupController: Initializing chromium process, singleProcess=true
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   chromium: [WARNING:resource_bundle.cc(304)] locale_file_path.empty()
[INFO] :   chromium: [INFO:aw_browser_main_parts.cc(65)] Load from apk succesful, fd=47 off=46184 len=3037
[INFO] :   chromium: [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.pak from, fd:48 off:229484 len:1089587
[ERROR] :  BluetoothAdapter: Bluetooth binder is null
[TRACE] :  Uploaded tiapp metadata with Appcelerator Platform!
[WARN] :   chromium: [WARNING:mailbox_synchronizer.cc(41)] MailboxSync not supported due to missing EGL image/fence support
[WARN] :   chromium: [WARNING:data_reduction_proxy_settings.cc(331)] SPDY proxy OFF at startup
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   AwContents: onDetachedFromWindow called when already detached. Ignoring
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   art: Attempt to remove local handle scope entry from IRT, ignoring
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xaec35c80, error=EGL_SUCCESS
[INFO] :   Choreographer: Skipped 47 frames!  The application may be doing too much work on its main thread.
[INFO] :   Choreographer: Skipped 40 frames!  The application may be doing too much work on its main thread.
[ERROR] :  chromium: [ERROR:buffer_manager.cc(313)] [.Parent-Compositor-0xaee39a90]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
[INFO] :   Choreographer: Skipped 40 frames!  The application may be doing too much work on its main thread.
[INFO] :   Choreographer: Skipped 50 frames!  The application may be doing too much work on its main thread.
[INFO] :   Choreographer: Skipped 53 frames!  The application may be doing too much work on its main thread.
[INFO] :   Choreographer: Skipped 34 frames!  The application may be doing too much work on its main thread.

Comments

  1. Ritu Agrawal 2014-06-11

    Moving this to engineering as I can reproduce the issue with the provided test case and the attached html file. I can only see the issue if webView.setUserAgent is used.
  2. Ed Stenger 2014-10-06

    This issue is still occurring in more recent releases of Titanium SDK Using build: 3.4.0.201409261227, SDK 3.3.0.GA and 3.4.0.GA Tested on these devices, but expect it is occurring universally: Samsung Galaxy S3 running Android 4.3, API 18 Samsung Galaxy S3 and S4 running Android 4.4.2, API 19 Motorola Droid Razr running Android 4.1.1, API 16 One additional note/observation: The select pop-up dialog does seem to instantiate, but UNDER the main window. If you close the main window, you are able to briefly view the dialog before the window closes completely. There doesn't seem to be any kind of workaround.
  3. Ronald Linasi 2014-12-05

    I have the same problem with select on remote sites on android. Without setting the userAgent the select works as aspected.
  4. Marcus Ilgner 2015-06-02

    I just have reproduced this with a current 4.0 build. After using setUserAgent, the web view behaves as follows: * the touch keyboard does not open anymore when focussing a text field. Using Titanium.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS allows entering text but provides bad UX since the keyboard does not close when no field has focus. * select boxes don't work at all. When closing the web view while the box has focus, the selection control can be seen for a very short time before being destroyed: it looks like it is instantiated *behind* the web view and thus not visible. In my opinion this is a grave bug that breaks an important UI component.
  5. Srikanth Sombhatla 2015-11-18

    A quick workaround is to create and add the web view in 'open' event of the window or tabgroup. This is to make sure that the web view is created in the context of the main window.
           var tabGroup = Ti.UI.createTabGroup({ exitOnClose: true });
           var window = Titanium.UI.createWindow();
           var adviceTab = Ti.UI.createTab({
               title : "Title",
               window : window
           });
           window.containingTab = adviceTab;
           tabGroup.addTab(adviceTab);
           tabGroup.open();
           
           window.addEventListener('open', function() {
       	    var webView = Titanium.UI.createWebView();
       	    webView.setUrl('select.html');
       	 	webView.setUserAgent("Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; SAMSUNG-SGH-I747 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
       	 	window.add(webView);
           });
       
  6. Chee Kiat Ng 2015-12-03

    Please use the workaround and comment if there are still issues.

JSON Source