• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
7
Question by Jimmy Heys · Jan 29, 2010 at 07:24 PM · webplayerstringwebwebpage-javascript

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?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image William Grand · Apr 23, 2010 at 08:21 PM 0
Share

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

avatar image user-2785 (yahoo) · May 28, 2010 at 07:36 AM 0
Share

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.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by jonas-echterhoff · Feb 04, 2010 at 11:01 AM

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?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image equalsequals · Aug 30, 2011 at 04:53 PM 0
Share

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

avatar image
0

Answer by Jeroen 3 · Feb 01, 2011 at 12:26 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image chrisMary · Jun 29, 2016 at 10:25 AM 0
Share

Same here... I'm trying to work with gamesparks to have a cloud save in JSON, one way works fine, when I save to the cloud, I get the string limit when I retrieve the remote data... Any workarounds ?

avatar image
0

Answer by CHaNGeTe · Jul 11, 2013 at 12:28 PM

I can't test it now, but does it work if you use String.Format("{0}", aVarWithTheData) as argument for the externalcall?

I think there is a problem with object types cast. This maybe enforces it to send the data as a string.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How would I go about getting the results of a javascript variable to a string inside script? 3 Answers

What kind of error handling does the WWW class have? 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

yield on WWW? or AssetBundleRequest? or both? 2 Answers

Getting focus on web player 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges