Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8293] iOS: Subsequently setting the html property of a webview does not show the changed html but shows blank content

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-04-05T08:29:16.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-07, Release 2.0.1
ComponentsiOS
Labelsregression, webview
ReporterDietrich Streifert
AssigneeStephen Tramer
Created2012-02-24T02:51:35.000+0000
Updated2012-06-22T16:26:25.000+0000

Description

Problem

In our app we create one instance of Ti.UI.WebView and reuse it for showing html content which is stored in a sql db. As the user navigates to different entries within a messages list, the new selected content is pushed into the webview by asigning the value to the html property of the webview. The first time the value is set, the content shows up as expected. If the value is set the second time the webview shows up empty.

Test case

Create a fresh mobile project and replace the default app.js with the following code:
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

var	button1 = Titanium.UI.createButton({
	title:'open webview window',
	width:220,
	height:40
});

win1.add(button1);

var winwebview = Titanium.UI.createWindow({  
    title:'Window with webview',
    backgroundColor:'#fff'
});

var webview = Titanium.UI.createWebView({
});

winwebview.add(webview);

var counter = 0;
button1.addEventListener('click',function(e)
{
   counter++;
   webview.html = '<h1>Counter is: ' + counter + '</h1>';
   tab1.open(winwebview,{animated:true});
});

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win2.add(label2);



//
//  add tabs
//
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  


// open tab group
tabGroup.open();

Build an run the app in simulator.

Tap on the button "open webview window".

The webview shows the line "Counter is: 1".

Navigate back to Tab 1 and tap again on the button "open webview window".

The webview should show the line "Counter is: 2", but the webview shows up empty.

With Titaniums SDK 1.8.0.1 and 1.8.1 this works as expected.

Comments

  1. Dietrich Streifert 2012-03-05

    The bug also occurs in Titaniums SDK 1.8.2 GA
  2. Dietrich Streifert 2012-03-06

    Posted on Q&A: http://developer.appcelerator.com/question/133230/ios-subsequently-setting-the-html-property-of-a-webview-does-not-show-the-changed-html-but-shows-blank-content
  3. Stephen Tramer 2012-03-26

    First bad commit: 53ffa8ad93c1f75c1e1a52a5fb4fa64ad112821a for TIMOB-7279
  4. Dietrich Streifert 2012-04-01

    @Stephen: I would be very glad to have this fixed in the upcoming SDK release 2.0.0. Any comments? Thank you.
  5. Stephen Tramer 2012-04-02

    Dietrich - We have already locked in non-critical fixes for our 2.0.0 release. This fix will appear on our continuous integration server when the bug is resolved.
  6. Dietrich Streifert 2012-04-02

    @Stephan: That's odd! I think that reusing a webview instance ist not a rare use case, so i suspect that there will be a lot of post 2.0.0 release complaints about this bug. But you may consider raising this bug to critical. This would allow the fix to make it into 2.0.0.
  7. Vishal Duggal 2012-04-05

    Fixed on master by PR #1907
  8. Vishal Duggal 2012-04-05

    Fixed on 2_0_X by PR #1935
  9. Eric Merriman 2012-04-06

    Vishal investigating message in console: "[WARN] couldn't load URL: app://com.appcelerator.timob8293/(null)". My app ID is com.appcelerator.timob8293. Not sure if this is related to our network problems, this fix, or something else.
  10. Eric Merriman 2012-04-06

    Verified fixed with SDK 2.0.1.v20120405211737 and Titanium Studio, build: 2.0.1.201204051443

JSON Source