|
Rank: Advanced Member Groups: Member
Joined: 5/6/2016 Posts: 30
|
Hi!
I have an application where I have to run JavaScript code on several webviews a lot. The problem is that I get this error when there are a lot of scriptcalls are called.
The scenario is the following:
- There is a list in one of the webviews - When the user press and hold the down arrow it will navigate down on the list (the selected lsit tiem will change as it should be) - I have to call a JSCode on every selectionchange which happens quite a lot while key hold - I get the above error, and this completely breaks the page
How can I solve this?
Thank you for the answer in advance!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You will need to troubleshoot your JavaScript code for this. This usually occurs when you have deep recursive calls. For example, if function A always calls itself then you will get this error immediately. You can either debug the page with the built-in remote debugger feature in EO.WebBrowser or use Google Chrome.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/6/2016 Posts: 30
|
There isn't any recursive calls in the JavaScript code and the page works fine when loaded in the browser. I give a code sample to how I use it: Quote: public void SendMessage(string callBackName, string messageJson) { var param = messageJson .Replace("\\", "\\\\") .Replace("'", "\\'"); var script = "window." + callBackName + "('" + param + "');";
var call = _webView?.QueueScriptCall(script); call?.OnDone(() => { if (call.Exception != null) { // only for debugging purpose } }); }
This function is called very frequently when the user is holding the arrow keys inside of a list (navigating between list items).
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, In that case you can try the following: 1. Update to the latest build if you have not done so. In early versions QueueScriptCall can re-enter that can cause strange problems. In the latest build QueueScriptCall no longer has re-entering issue; 2. Try to set this property to true: http://www.essentialobjects.com/doc/eo.base.runtime.enablelargeaddressspace.aspx3. If step 1 and step 2 does not solve the problem, please try to isolate the problem into a test project and send the test project to us. See here for more details: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/6/2016 Posts: 30
|
Currently I'm trying to create a sample to reproduce the bug and something came to my mind.
Sometimes the messageJson or param string is really long (I found one which is 80 000 character long and there can be even longer ones), can this cause the problem? Because this can mean that the JSCode which will be run can be really big.
Edit: In my Sample I just used one of these long Json strings and I get an OutOfMemory exception:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Text.Encoding.GetBytes(String s) at EO.Internal.afk.a(i0 A_0, String A_1, Boolean A_2) at EO.Internal.aq9.a(String A_0, Boolean A_1) at EO.WebBrowser.WebView.g() at EO.WebBrowser.WebView.QueueScriptCall(ScriptCall call) at EO.WebBrowser.WebView.QueueScriptCall(String script) at EO.WebBrowser.RangeError.Sample.MainWindow.<ButtonBase_OnClick>b__5_0() in \EO.WebBrowser.RangeError.Sample\MainWindow.xaml.cs:line 68
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Yes. You definitely want to overcome this error first. We need to convert the string into a byte array and send it over to the browser engine, the browser engine will then pass it to the JavaScript engine to run. If any step run into out of memory error, then it's an issue and that needs to be fixed first.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/6/2016 Posts: 30
|
So, if I understand it correctly. It's me, who have to deal with this error, right?
Could you give me some hint? Because I can't gurantee a maximum length of these messages. These are Json strings most of the time, and sometimes they contain a lot of data, thus the strings can grow very big.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Yes. You must solve such problems yourself. This is like you overload a boat and it sinks. The only solution for such case is to decrease your load. If the only way to decrease your load is to change your design, then that's what you have to do. For example, if your Json string contains an array with a lot of elements, then you might want to send multiple chunks over multiple calls.
|
|