Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4771] Android: apiXmlNodeCloneNode fails with exception

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T16:15:57.000+0000
Affected Version/sRelease 1.7.1
Fix Version/sSprint 2011-30, Release 1.8.0
ComponentsAndroid
Labelsmodule_xml, qe-testadded
ReporterOpie Cyrus
AssigneeEric Merriman
Created2011-07-25T15:17:27.000+0000
Updated2014-06-19T12:46:11.000+0000

Description

When trying to clone node, exception is thrown: "07-25 16:29:33.160 13642 13651 E KrollMethod: (kroll$1: app://app.js) [7,2569] Exception calling kroll method cloneNode, invocation: null ] 07-25 16:29:33.160 13642 13651 E KrollMethod: org.w3c.dom.DOMException 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.apache.harmony.xml.dom.NodeImpl.setNameNS(NodeImpl.java:228) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.apache.harmony.xml.dom.ElementImpl.(ElementImpl.java:51) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.apache.harmony.xml.dom.DocumentImpl.createElementNS(DocumentImpl.java:337) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.apache.harmony.xml.dom.DocumentImpl.shallowCopy(DocumentImpl.java:157) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.apache.harmony.xml.dom.DocumentImpl.cloneOrImportNode(DocumentImpl.java:209) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.apache.harmony.xml.dom.NodeImpl.cloneNode(NodeImpl.java:77) 07-25 16:29:33.160 13642 13651 E KrollMethod: at ti.modules.titanium.xml.NodeProxy.cloneNode(NodeProxy.java:122) 07-25 16:29:33.160 13642 13651 E KrollMethod: at ti.modules.titanium.xml.NodeProxyBindingGen$24.invoke(NodeProxyBindingGen.java:931) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.appcelerator.titanium.kroll.KrollCoverage$KrollFunctionCoverage.call(KrollCoverage.java:213) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.appcelerator.titanium.testharness.Test_harnessActivity$1.run(Test_harnessActivity.java:90) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:219) 07-25 16:29:33.160 13642 13651 E KrollMethod: at android.os.Handler.dispatchMessage(Handler.java:95) 07-25 16:29:33.160 13642 13651 E KrollMethod: at android.os.Looper.loop(Looper.java:143) 07-25 16:29:33.160 13642 13651 E KrollMethod: at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) 07-25 16:29:33.551 13642 13651 D dalvikvm: GC_FOR_MALLOC freed 9833 objects / 572048 bytes in 95ms 07-25 16:29:33.840 13642 13651 W TiConvert: (kroll$1: app://app.js) [14,3258] Unsupported type class org.appcelerator.kroll.KrollProxy$1 07-25 16:29:33.918 13642 13651 D dalvikvm: GC_FOR_MALLOC freed 9055 objects / 556920 bytes in 54ms"

Comments

  1. Bill Dawson 2011-07-26

    Google bug that is fixed in Honeycomb: http://code.google.com/p/android/issues/detail?id=2735
  2. Bill Dawson 2011-07-26

    Changed NodeProxy code to simply display warning when cloneNode called in pre-Honeycomb versions. Use this as test case and try both in pre-Honeycomb and Honeycomb or later:
       //Titanium.Network // (workaround for TIMOB-3465)
       var xmlString = '<a b="c"><d e="f"/></a>';
       var doc = Ti.XML.parseString(xmlString);
       var elem = doc.documentElement.firstChild;
       if (Ti.Platform.osname === 'android' &&
       		!isNaN(parseInt(Ti.Platform.version)) &&
       		parseInt(Ti.Platform.version) < 3) {
       	Ti.API.warn("Call to .clone() will probably throw DOMException.  You should also see another warning from core code prior to the exception.");
       }
       var clone = elem.cloneNode(false);
       
    * In pre-Honeycomb (pre-3.0) you should get a DOMException on screen. Check logcat, look above the exception stack traces, and make sure you see two warnings, one from the Javascript code above (and thus beginning with W/TiAPI) and one from our NodeProxy (thus beginning with W/TiNodeProxy). * In Honeycomb or later, you should get no exceptions, and you should not see any of the two warning messages described in the previous bullet.
  3. Don Thorp 2011-07-29

    review and test.
  4. Natalie Huynh 2011-12-06

    Tested with 1.8.0.1.v20111205164258 v8/rhino on Galaxy 10.1 (3.1) Droid 1 (2.2.2) Nexus S (2.3.6) Emulator (4.0) Pre-HoneyComb: Do not get DOMException but get this warning W/TiAPI ( 1885): Call to .clone() will probably throw DOMException. You should also see another warning from core code prior to the exception. W/TiNodeProxy( 1885): (KrollRuntimeThread) [497,711] cloneNode will often throw exception in versions prior to Honeycomb.
  5. Natalie Huynh 2011-12-06

    open to add label
  6. Michael Pettiford 2012-01-04

    Reopening/closing to add/remove labels

JSON Source