History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5176
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: P0 P0
Assignee: Philip Romanik
Reporter: Dan Swaney
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

When using IE 7: Repeated calls to <text>'s setText() will eventually throw javascript errors

Created: 30/Nov/07 12:07 PM   Updated: 08/Feb/08 09:01 AM
Component/s: Kernel - DHTML
Affects Version/s: 4.0.6/Jujube
Fix Version/s: RingDing (4.1)

Time Tracking:
Not Specified

File Attachments: 1. File LPP-5176.tar (4 kb)
2. File test_tabs.lzx (2 kb)

Environment:
Using OpenLaszlo 4.0.6 Server with lzr=dhtml

Severity: Blocker
Fixed in Change#: 7,617
Fixed in branch: trunk
Runtime: N/A
Fix in hand: False


 Description  « Hide
Using Internet Explorer 7 and OpenLaszlo 4.0.7, if calling a <text> element's setText() method every second, within 10-20 seconds javascript errors will appear. Although clicking 'no' to not debug when the debugger dialog appears (every second) allows the app to continue to run normally -- the dialogs make the app unusable by a user.

The error message from IE is: 'Error: 'style' is null or not an object.

The Microsoft Script Debugger shows a stack trace similar to the following.
The numbers start at the top lzx code call and traverse the stack to show the
methods called down to the error.

myapp.js:
1. label_currentTime.setText( $2 )

lps/includes/lfc/LFCdhtml.js:
2. var $3=this.getTextWidth()

3. getTextWidth:function(){ return this.sprite.getTextWidth() }

4. LzTextSprite.prototype.getTextWidth=function() { ...
    return this.getTextSize( this.text, this.resize ).width

5. $7.style.display="block"
(Note: #5 is where IE caught the exception.)


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dan Swaney - 30/Nov/07 12:31 PM
I did some additional testing using 4.0.7 and the same problem occurs.

The problem occurred after 2 min 30 seconds ( approx 150 calls to setText() ).

Dan Swaney - 30/Nov/07 12:33 PM
Note sure if this helps, but the exact error message was:

Error: A runtime Error has occurred.
Do you wish to Debug?

Line: 3602
Error: 'style' is null or not an object.

Dan Swaney - 30/Nov/07 01:16 PM
This small test reproduces the same problem.
(Make sure to use '?lzr=dhtml&lzt=html' with the URL.)

Click on 'Count' button to start the counter. This will update the <text> by calling setText() every 1ms.

Counter will stop after 992 calls with a javascript error.

Note: I'm not using it every 1ms -- but every 1 second -- but this speeds up getting to the problem without waiting 2 minutes.

Dan Swaney - 30/Nov/07 04:13 PM
See 'Attached File' for sample code to repro the problem

Dan Swaney - 03/Dec/07 07:31 AM
Reminder: Counter will stop after 992 calls consistently using IE...

...and requires only '?lzr=dhtml' to repro (&lzt=html isn't needed).

Dan Swaney - 06/Dec/07 06:51 AM
This also affects RingDing Revision 7457 for OpenLaszlo 4.1.x

André Bargull - 06/Dec/07 11:30 AM
- made testcase smaller
- added another test which shows a bug in the "LzTextSprite" text-style cache

[just apply the patch to see what's actually broken in LzTextSprite]

Also see LPP-3617.

André Bargull - 08/Dec/07 03:26 PM
created LPP-5220 to track the other bug in the text-style cache.

Philip Romanik - 19/Dec/07 11:18 AM
Change 20071218-Philip-6 by Philip@Philip-DC on 2007-12-18 16:27:25 EST
     in /cygdrive/f/laszlo/svn/src/svn/openlaszlo/trunk
     for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fixed text size caching in IE7

New Features:

Bugs Fixed: LPP-5176

Technical Reviewer: max
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
LzTextSprite.getTextSize() has a cache to save computation, and this cache is erased every 1000 entries. The problem is the counter is also zeroed. In IE, the tag name includes the counter value and the name cannot be reused without generating javascript errors. I think IE is trying to reuse the name, but the object has been deleted.

The fix is to never zero the counter. The cache is erased but the counter value is set to its old value.


Tests:
Run test in LPP-5176 in IE7/dhtml. Also tested in FF/dhtml.

Files:
M WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20071218-Philip-6.tar


Dan Swaney - 02/Jan/08 04:02 PM
Problem still occurs using Ring Ding Build 4.1.x.7695.

When _sizecache.counter reaches 1000, Internet Explorer 7 displays:

Error: A runtime error has occurred. Do you wish to debug?
Line: 1889
Error: 'style' is null or not an object.

The line it fails on is in 'LzTextSprite.js' when calling:
....$8.style.display="block"; (where $8 is the mdiv variable and style is not defined)

I tried adding the following change to 'LzTextSprite.js' to guard against this, but it also fails stating:
"Object doesn't support this property or method" when calling '__setAttr()' on the mdiv.

Note: '>>' indicates lines changed -- periods added to preserve indention.

[snippit from LzTextSprite.js]
............var tagname = this.multiline ? 'div' : 'span';
............var mdiv = _textsizecache[tagname];
............if (mdiv == null) {
................mdiv = document.createElement(tagname);
................Lz.__setAttr(mdiv, 'style', style);
................root.appendChild(mdiv);
................_textsizecache[tagname] = mdiv;
............}
>>.......else if( mdiv.style == null ) {
>>..............Lz.__setAttr( mdiv, 'style', style );
>>............._textsizecache[tagname] = mdiv;
>>.......}
[end snippit]

Can you help?

Dan Swaney - 03/Jan/08 06:42 AM
To work-around the problem, I've added the following changes to 'LzTextSprite.js'. This appears to work, but I'm not sure about the side effects.

Note: '>>' indicates lines added -- periods added to preserve indention.

[snippit from LzTextSprite.js]
........mdiv.innerHTML = string;
>>...if( typeof( mdiv.style ) == "undefined" )
>>...{
.............mdiv.style.display = 'block';
>>...}
........size.width = mdiv.offsetWidth;
........size.height = mdiv.offsetHeight;
>>...if( typeof( mdiv.style ) == "undefined" )
>>...{
.............mdiv.style.display = 'none';
>>...}

Dan Swaney - 03/Jan/08 06:45 AM
Correction...

[snippit from LzTextSprite.js]
........mdiv.innerHTML = string;
>>...if( typeof( mdiv.style ) != "undefined" )
>>...{
.............mdiv.style.display = 'block';
>>...}
........size.width = mdiv.offsetWidth;
........size.height = mdiv.offsetHeight;
>>...if( typeof( mdiv.style ) != "undefined" )
>>...{
.............mdiv.style.display = 'none';
>>...}
[end snippit]

Is this a solution that should be committed to the trunks for Ring Ding and/or Wafflecone?

Mamye Kratt - 24/Jan/08 04:07 PM
(trunk 4 build r7833)

----- Original Message ----- From: "Dan Swaney"
<dswaney@echostorm.net>
To: <mamye@laszlosystems.com>
Sent: Thursday, January 24, 2008 5:06 PM
Subject: LPP-5176 is Fixed?

Hi Mamye,

LPP-5176 is marked fixed, but I still had to patch OL to prevent
problems during a refresh or close down of the browser window.
See LPP-5347 for details.

Also, it seems as though over time, text will not resize properly
causing clipping and strange word-wrapping effects on text
elements. My guess is this occurs after the 1000-th text update
occurs.
I downloaded the latest 4.1.x build and will try to see if these
problems fix themselves -- although last week I did this and
images weren't resizing (possibly after a certain size of the
SOLO DHTML Laszlo App).

 =Dan=

On Jan 24, 2008, at 6:40 PM, Mamye Kratt wrote:

Hi Dan,

I haven't checked the fix for LPP-5176 yet. Which release are you
using? r7833?

Mamye

From Dan:
Yes -- I'm using r7833.


Philip Romanik - 24/Jan/08 05:07 PM
Are you using your original test_tabs.lzx app to test?

I just tried it on a clean version of trunk (r7885). I ran test_tabs.lzx for 5000 iterations on IE7 without any errors.

Dan Swaney - 28/Jan/08 01:21 PM
It's not easily reproducible with the attached examples.

I'm having major problems within an application that continuously updates 24 text fields per second.

I'm working on building a small test app to type reproduce this to help with fixing this
since I can't post the entire application.

Dan Swaney - 29/Jan/08 01:22 PM
I finally was able to repro this with a small example.
I'll be posting it shortly...

Philip Romanik - 08/Feb/08 09:01 AM
See LPP-5390. This is the current bug that affects FF and IE.

From Dan:

Here's the state of the tickets:

1. LPP-5389 (sub-task to LPP-5176) needs to be removed -- I added it by accident.

2. LPP-5176 should be re-closed -- LPP-5390 tracks the new problem
While similar in cause, LPP-5390 affects both Firefox and IE
(LPP-5176 addressed an IE-only bug)

3. LPP-5394 is a sub-task to change the title of LPP-5390. I cloned LPP-5176,
but didn't realize it wouldn't let me edit the title. I also didn't realize the
initial description couldn't be edited -- it shows the description of
LPP-5176. I added the new description as a comment.