Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-7808

Android: Webview reloads when removed and re-added. Regression from 1.7.5

    Details

      Description

      This is a regression. When you try to move a webview from one view to another on Android using Titanium SDK 1.8.x and further, the webview reloads. It doesn't do this on iOS using any Titanium SDK. And it doesn't do it on Android when using Ti SDK 1.7.x.

      The test case below shows that even removing the webview from a window and putting it back again makes it reload.

      app.js

      var win = Ti.UI.createWindow();
       
      // It doesn't matter if the webview is created using `html` or`url`
      // When loaded, the webview shows the current timestamp.
      var webview = Ti.UI.createWebView({
          html: '<html><head></head><body><script>var now = Date.now(); document.body.innerHTML = now;</script></body></html>'
      });
       
      var onload = function(){
          // Actually, we could see that the load event would fires twice on Android,
          // but I want to really prove that the content actually reloads
          webview.removeEventListener('load', onload);
       
          var before = webview.evalJS('now');
       
          // Just removing the webview and adding it back again makes it reload on Android when using Ti SDK 1.8.x
          win.remove(webview);
          win.add(webview);
       
          // Give Android time to breathe
          setTimeout(function(){
              var after = webview.evalJS('now');
              alert('The webview ' + (before == after ? "HASN'T" : "HAS") + ' reloaded!');
          }, 500);
       
      };
      webview.addEventListener('load', onload);
       
      win.add(webview);
      win.open();
      

      The issue was raised by one of the Appcelerator Titans.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pwang Ping Wang
                Reporter:
                vjoshi Varun Joshi
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code