Passing large string from javscript to Nacl module

48 views
Skip to first unread message

Shilpi Agarwal

unread,
Aug 28, 2011, 6:58:36 PM8/28/11
to Native-Client-Discuss
Hii,

I am making a simple program of counting a number of words in string.
I am passing data to Nacl mdoule in string.
But when the length of the string is too large, it is not working.
Please suggest em how can I pass a large string to Nacl module.

Assaf Raman

unread,
Aug 28, 2011, 8:29:13 PM8/28/11
to Native-Client-Discuss
Divide the large string to smaller strings and loop.

Darin Fisher

unread,
Aug 28, 2011, 8:35:09 PM8/28/11
to native-cli...@googlegroups.com
On Aug 28, 2011 5:34 PM, "Darin Fisher" <da...@google.com> wrote:
> An alternative is to pass data using a file. You can create a file from JS
> using the FileSystem and FileWriter interfaces, and then read it using
> PPB_FileSystem and PPB_FileIO. Obviously this is probably only a win when
> you need to exchange a lot of data.
>
> There is another related thread that details creating a Blob and reading it
> via PPB_URLLoader. That only works for passing data from JS to NaCl.
>
> Regards,
> Darin
> On Aug 28, 2011 5:00 PM, "Shilpi Agarwal" <shil...@gmail.com> wrote:

jonovos

unread,
Aug 28, 2011, 9:49:36 PM8/28/11
to Native-Client-Discuss
How OMINOUS! I have a project that will depend on sending a large
range of possible string sizes. -- For good software engineering, we
must determine the actual string size limits, I assume using a typical
styled [JS-call] NaClThingamabobModule.postMessage( 'message
content' ) ... so, original poster, Shilpi Agarwal, would you please
put up a code fragment that shows how you are getting this error??

jonovos

unread,
Aug 29, 2011, 1:16:45 PM8/29/11
to Native-Client-Discuss
In response to e-mail from Shilpi Agarwal ==> " If the length of the
string is more than 64 KB, it is getting failed. I am sending the
string in the same way you mentioned in your post." ===> I just tried
a large 80kb block of text. It was pure printable ASCII, that is,
elements of set {' ',...,'~'} ( {0x20,...,0x7e} ), plus LF's
{'\n'} ( {0x10} ) ... and I could not reproduce an error. I am
using SDK 0.5.1025 (2011-08-10) ===> Is it possible that your strings
contain characters that are outside this character set? Is it possible
that the string handling is not right?

David Michael

unread,
Aug 29, 2011, 1:38:02 PM8/29/11
to native-cli...@googlegroups.com
Hmm. One possibility is that the string is not valid UTF-8:
I believe we're running a check on the string and throwing it away if it is not valid. The failure would happen when calling PPBVar.VarFromUTF8, and it would yield a Var with type PP_VARTYPE_NULL. If you don't check the type before calling postMessage, postMessage will happily send a Null Var.

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To post to this group, send email to native-cli...@googlegroups.com.
To unsubscribe from this group, send email to native-client-di...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/native-client-discuss?hl=en.


Reply all
Reply to author
Forward
0 new messages