I recently tested a Cappuccino app I was working on with Chrome and Safari. I get the error:
INVALID_STATE_ERR: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.
The lack of information is frustrating. What object and where did I attempt to use it? Chrome tries to answer the second question but the line number it gives, 465, doesn't mean anything when the file it gives is just 94 lines long. Without more information I don't even know where to start looking.
First, I don't really know a thing of Cappucino or what you're trying to do. But I've seen this when working with Qt WebKit and JavaScript objects. It happened after javascript window object was cleared, e.g. if I didn't load my native JS objects to WebKit after new page was loaded.
This basically means, you are trying to use internally deleted JavaScript object.
This problem occured for me because I used the Audio API like this:
But this is not correct because the play() function is async. Instead you need to use the then function of the returned Promise.
This can also happen when Javascript tries to
document.write()
into an XHTML page (Content-Type: application/xhtml+xml
).I've seen this happen when trying to dynamically write an
input[type="file"]
element with itsvalue
attribute set.When i removed the
value
attr from what i was injecting it all worked.In a sense, I see this error as meaning "you tried to do something that specification does not allow" based upon this article here -- http://designbyjeeba.blogspot.com/2011/04/dreaded-invalidstateerr-dom-exception.html
Chrome canary offers stack traces for DOM Exceptions!
In this case I believe the issue was stemming from trying to draw images to canvas using a pattern fill with an image that was not fully loaded. This question was related to Cappuccino issue 811 and my reasoning is based on aparajita's advice to make sure the image is loaded before attempting to use it as a pattern fill.
Still, this error is frustratingly opaque considering the key piece of information (what object was called) is not obvious and the places it can crop up in are varied.