x


What is the maximum byte length of Application.ExternalCall? (and oh yea, it doesn't escape strings correctly)

We've been experiencing problems transferring long chunks of data through the Application.ExternalCall method. it seems like there is a hard limit to the number of bytes that can be pushed to JavaScript. This is NOT a limitation on the JS side. We have successfully sent the same data to and from other embedded objects (ex: SWF to SWF). Our research has yielded a result of around 12560 bytes. I would like to know, if this is a known issue... and if so, what is the real limit?

and oh yea: The method doesn't properly escape the characters passed to it. It seems that it escapes quotes (" => \") as expected, but does not escape slashes and/or line breaks (\,\t,\n,\r,\f) which causes an unterminated string error on the JS side. Not to mention any text that already contains escaped characters breaks (example: \" => \\" should be: \" => \\\"). There are 2 (that we can think of) workarounds for this:

  1. Escape them (the slashes and line breaks) ourselves (but NOT the quotes) before they get passed through the Application.ExternalCall or

  2. Use the WWW.EscapeUrl method to URL encode the value and decode them on the other side

Both of these methods seem to work, but the url encoding adds a considerable amount more characters to what we are sending. Thus, reducing the amount of data we can actually send at one time.

Has anyone else dealt with this?

more ▼

asked Jan 29 '10 at 07:24 PM

Jimmy Heys gravatar image

Jimmy Heys
66 1 2 3

I have the same issue. I am trying to send the Base64 representation of a screenshot to Javascript to eventually send to the printer (print screen functionality from Unity3D). But I continue to received "unterminated string literal" errors in the Error Console in Firefox.

I'm sending a string of about 30,000 characters

Apr 23 '10 at 08:21 PM William Grand

I also encountered this problem when sending long arrays (> 30000 items). I worked around it by splitting up in multiple calls and assembling on the javascript side.

May 28 '10 at 07:36 AM user-2785 (yahoo)
(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest

We have the same problems with a game we're creating, which passes fairly large JSON files from Javascript to Unity. Once they reach ~ 16KB, Unity chokes on it. (Un)escaping indeed is buggy too.

more ▼

answered Feb 01 '11 at 12:26 AM

Jeroen 3 gravatar image

Jeroen 3
1

(comments are locked)
10|3000 characters needed characters left

I don't see any reason for there to be a limit, so this sounds like a bug to me. Can you file a bug report with an example script which shows the problem, and details on which platforms (browser, OS) you are experiencing the problem on?

more ▼

answered Feb 04 '10 at 11:01 AM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.8k 7 23 104

My team has hit this same limitation (Unity 3.3) when sending lengthy JSON formatted strings to the browser, are there any new developments?

Aug 30 '11 at 04:53 PM equalsequals
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5087
x813
x420
x212
x11

asked: Jan 29 '10 at 07:24 PM

Seen: 2074 times

Last Updated: Aug 30 '11 at 04:53 PM