blackberry / WebWorks

BlackBerry WebWorks for Smartphones is a platform for building deeply integrated web applications for BlackBerry smartphones
http://developer.blackberry.com/html5
268 stars 51 forks source link

"SCRIPT_JAVA_INVOKE_FUNCTION failed" for blackberry.utils.stringToBlob #118

Closed sterlingwes closed 12 years ago

sterlingwes commented 12 years ago

Hoping someone can help me get more detail on this error. The error referenced above is produced in my Web Inspector console when calling blackberry.utils.stringToBlob(). I'm testing on my Blackberry Bold 9900 with OS 7.

I'm calling blackberry.utils.stringToBlob() with a JSON string returned by JSON.stringify. I initially used the default encoding, but have also tried UTF-8 and BASE64 (after running it through decodeURIComponent(escape(window.atob( jsonString ))).

The issue appears to be content-related, as it runs fine with some content, and not with others, reliably. The content I'm trying to save is a JSON representation of a web page (after significant parsing and formatting, which is converted from DOM elements to string, and saves HTML in a format like: {"title":"<h1>Title</h1>","content":"<p>Page content with <b>HTML</b> <i>tags</i>."}.

I'm wondering if there's any known length or character encoding issues that would cause this error to occur? I don't know enough about the Java environment to debug this properly... I've been doing all my debugging in the Web Inspector to date. The page I'm testing on that produces this error has a meta encoding tag specifying UTF-8.

Please help! This is exceedingly frustrating.

sterlingwes commented 12 years ago

Looks like it does have to do with string length. The documentation at: https://developer.blackberry.com/html5/apis/blackberry.utils.html#.stringToBlob makes reference to acceptable string lengths but it's vague for Base64. Perhaps someone who understands the native blob format can enlighten us as to why that is?

My solution is to split the file up in chunks.