37

My application engine runs inside a WebView. It spans different IFRAMES. Both the main application html and the iframes html are on android_assets. On Android 3.x no problems ever. Same on chrome browser, etc.

If I create an IFRAME (createElement -> appendChild) the iframe is created.

When I load stuff in it (iframe.src="url" <> iframe.contentWindow.location.href="url") ... IT REPLACES THE MAIN APPLICATION!! (instead of loading into iframe)

Already tried:

  • window.setTimeout to delay the loading... failed.
  • in webview, inject X-Frame-Options=SAME_ORIGIN as header into any loaded page -> failed
  • creating the iframe, setting sandbox=same_origin,allow_scripts -> failed

Anybody with similar problems? Or can someone help me find documentation about WebView ICS bugs vs Honeycomb?

Also found many other strange issues... is ICS really this buggy? :S :S

AakashM
  • 62,551
  • 17
  • 151
  • 186
rupps
  • 9,712
  • 4
  • 55
  • 95
  • I have exactly same problem with PhoneGap everything works fine with previous versions of Android – nLL Feb 22 '12 at 18:51
  • I think ICS switched the Webkit components to those of the mobile Chrome source. (I noticed that it now uses SPDY where the old WebView didn't.) The bug might be found by looking at the new source – nmr Feb 27 '12 at 01:36
  • 1
    First of all there is a Massive Changes regarding Web in ICS. Secondly I had an issue but not like you it was with my game which was running fine on all devices except those who are running ICS. I resolved the issue but not adding any custom frame layouts. I think you better search Google for what changes they made to ICS. Then you will find the solution. – Jawad Amjad Mar 09 '12 at 08:27
  • I encountered similliar bugs before, here is an issue related http://code.google.com/p/android/issues/detail?id=23362 – Cedric Fung Mar 19 '12 at 15:53

1 Answers1

2

Sirs, I had the same problem when using Phonegap (Apache Cordova) and IFrames in Android Ice Cream Sandwich (4.0.3).

To solve this problem, I had to edit Apache Cordova Source Code. I changed the org.apache.cordova.CordovaWebViewClient.java file, and commented this part of the code, and included the last line (return false;).

So it now looks like this:

    // All else
    //        else {
    //
    //            // If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity.
    //            // Our app continues to run.  When BACK is pressed, our app is redisplayed.
    //            if (url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || ctx.isUrlWhiteListed(url)) {
    //                this.ctx.loadUrl(url);
    //            }
    //
    //            // If not our application, let default viewer handle
    //            else {
    //                try {
    //                    Intent intent = new Intent(Intent.ACTION_VIEW);
    //                    intent.setData(Uri.parse(url));
    //                    ctx.startActivity(intent);
    //                } catch (android.content.ActivityNotFoundException e) {
    //                    LOG.e(TAG, "Error loading url "+url, e);
    //                }
    //            }
    //        }
    //        return true;
    return false;

This problem only happens on Android ICS, but I changed the code for all my apps. I'm still doing tests.

In my analysis, it seems that when you try to load a page inside a iFrame, the Android WebView on ICS interprets it as a new page request, and IT REPLACES THE MAIN APPLICATION!!, or in other words, it OPENS the requested page in the hole parent window.

I left the rest of the code untouched.

I hope it helps, like it did for me.

Best regards.

Alexandre Almeida

  • I'm late on saying MANY THANKS! stopped for a while android development but I will have to face this issue shortly. – rupps Oct 28 '12 at 16:23