×
Namespaces

Variants
Actions

Archived:JavaScript halted with "script is too big" error causing Symbian Web Runtime app freeze (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Tested with
Devices(s): 5800 XpressMusic, 5230 XpressMusic, E63, E71..
Compatibility
Platform(s): S60 3rd Edition Feature Pack 1, S60 3rd Edition FP 2, S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
Article
Keywords: "script is too big", MD5 JavaScript algorithm
Created: jaaura (30 Jul 2009)
Last edited: hamishwillee (01 Aug 2012)

Contents

Overview

Running heavy scripts causes “script is too big” error after 200.000 JavaScript statements on S60 3rd edition feature pack 1, S60 3rd edition feature pack 2 and S60 5th edition devices, excluding Nokia N97 and S60 3.2.2 devices which have the browser version 7.1 or later.

Description

There is a 200.000 limit in the JavaScript statement count in Web Runtime environment. Any heavy script, for example commonly used MD5 JavaScript algorithm, is halted after too many successive calls, resulting into a “script is too big” error and freeze of the widget. This will especially affect execution of complex and long running widgets.

How to reproduce

Download MD5 JavaScript algorithm and create following test harness. Execute it and let it iterate approximately 530 times.

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


function startLoop() {	

  textArea = document.getElementById("text");	
  var counter = 0;

  var next = function(){ 			

   var str = Math.round(Math.random()*1000)+"";

   try{
      var md5str = hex_md5(str);
   }
   catch (err) {
      alert(err);
   }		

   ++counter;
   textArea.innerHTML = counter + ": " + str + "<br>MD5:" + md5str;
   setTimeout(next, 50);		
 }	
 next(); //start the endless loop
}

Solution

There are ways to reset the JavaScript statement counter. Calling setTimeout with a string instead of a function pointer forces the parser to parse the string and also to reset the execution counter. Call setTimeout("void()",0); in areas of the widgets that are executed frequently. Alternatively setInterval can be used to achieve the same, with interval like 5 seconds and a call to void(): setInterval("void()",5000);

This problem does not impact Nokia N97 device or S60 3.2.2 devices which have the browser version 7.1 or later. Upcoming firmware updates for older devices may include a fix. Therefore it is recommended to include this fix in the Web Runtime widgets just in case.

This page was last modified on 1 August 2012, at 07:41.
57 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×