Solved

Knockout .js applying bindings to large model - timeout and uncatchable exception

Posted on 2014-12-16
20
65 Views
Last Modified: 2015-08-11
Technology stack:

* JDK 1.8u25
* KnockoutJS v3.1.0
* JQuery 1.9.1
* WebView and WebEngine

We have an object in our Java environment representing a structured document. Using Java 1.8 u25.

We wish to render it in a JavaFX WebView using custom Knockout.js bindings.

When we call ko.applyBindings() on the model, we get results as follows:

When the number of ‘rows’ in the data structure is < 400, the document renders successfully.

When the number increases beyond this point, we never get past the ko.applyBindings() line in our initialising function.

We don’t appear to get meaningful, if any catchable exceptions with Knockout.js - the document fails to render and gives us some very unexpected output e.g. the output for a context which isn’t in the model.

We don't have this problem when we run the same function in the browser (Chrome)
0
Comment
Question by:butterhook
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
20 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 40502405
Posting JavaScript questions in the Java TA is not appropriate, and might make your question less likely to be answered. http://technojeeves.com/joomla/index.php/free/127-javascript-is-not-java
0
 
LVL 1

Author Comment

by:butterhook
ID: 40502432
Thanks CEHJ for the suggestion - however as you can see we are using Knockout.js inside a WebView component of a JavaFX project so it is actually relevant, as the problem we are facing is inside that environment rather than a browser.

Also we are well aware that Javascript isn't Java.
0
 
LVL 43

Expert Comment

by:Rob
ID: 40503801
Apologies in advance if I ask too many questions regarding the java side of things as my background is javascript and knockout.

What version of javaFX are you running?  It seems that 2.2+ is required for HTML5

When the number of ‘rows’ in the data structure is < 400, the document renders successfully.
Is the 'rows' an observableArray?  It would help to see the model (if only the relevant parts).

Is it possible there a memory restriction for any javascript objects within the WebView/JavaFX?
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 1

Author Comment

by:butterhook
ID: 40504341
Hi Rob, Thanks for getting back to us.

Yes, the 'rows' are part of a model. Will see if I can get you the relevant parts as soon as I can as well as the info regarding JavaFX version.

Yes, all our evidence points to the memory restriction for Javascript objects within WebView/JavaFX.

Would you expect a memory restriction in the browser environments you work in?
0
 
LVL 43

Expert Comment

by:Rob
ID: 40504421
Thanks that info will be good to know.

Yes there are memory limitations but they are not so much of an issue as they are only limited by the operating system and hardware of the client machine. Both of which outstrip anything we would need to do in the browser.
That's not to say they wouldn't crash.

I have a fairly complex model that I use daily,  with upwards of 200 items in an observable at a time. At times it runs slow but more so on my phone and tablet rather than my laptop.
0
 
LVL 1

Author Comment

by:butterhook
ID: 40504816
Hi Rob,

The JavaFX version is bundled with JDK 1.8u25.

Will get back to you with parts of the model when possible.

Charlie
0
 
LVL 1

Author Comment

by:butterhook
ID: 40508931
Hi Rob,

Are you familiar with Java development, as we have a test case project created? Or is your expertise mainly web and browser?

Charlie
0
 
LVL 43

Expert Comment

by:Rob
ID: 40509992
Hi Charlie

Unfortunately, it's web based development. It's been 10+ years since I used java (basic structures, applets, forms etc)

Happy to help but understand if you want to get other java specific programmers involved.  In fact, there's another expert I'll ask if they can take a look too.

Rob
0
 
LVL 1

Author Comment

by:butterhook
ID: 40531126
Still looking into this - will post updates when we have some, in the hope that we will help someone else!
0
 
LVL 43

Expert Comment

by:Rob
ID: 40531168
I'd also suggest Requesting Attention to get a moderator to send out alerts to other experts.
0
 
LVL 1

Author Comment

by:butterhook
ID: 40544038
Thanks for keeping an eye on this Rob - did you ask the other expert you were considering?

Many thanks!
0
 
LVL 43

Expert Comment

by:Rob
ID: 40544144
Sorry things got a bit crazy around new year but I've since sent the message.
0
 
LVL 1

Author Comment

by:butterhook
ID: 40544412
(y)
0
 
LVL 36

Expert Comment

by:mccarl
ID: 40550581
@butterhook,

I was asked by Rob to look into this from a Java perspective but unfortunately, I don't have any experience with JavaFX and WebView, and so I don't think I can be much help.

we have a test case project created
Just to clarify, are you saying that you have a self-contained example that demonstrates the issue that you are seeing? If so, it still could be worthwhile posting it here for us to look at.
0
 
LVL 43

Expert Comment

by:Rob
ID: 40552415
Not sure if this helps but it seems that there is an API written specifically to include knockout and its implementation: http://bits.netbeans.org/html+java/dev/overview-summary.html
0
 
LVL 1

Author Comment

by:butterhook
ID: 40557544
Thanks all - I believe we have found the source of the issue and will update the thread in due course.
0
 
LVL 43

Expert Comment

by:Rob
ID: 40558693
Great news. As an avid knockout developer I'd be keen to hear what's fixed it.
0
 
LVL 1

Accepted Solution

by:
butterhook earned 0 total points
ID: 40917124
This issue was a memory leak in the JDK whereby large page sizes caused crashes.

We resolved it by using 'virtual pagination' so the document didn't have to be completely loaded, but still appeared to be a single larger document.

Hoping the bug is dealt with in newer versions of the JDK!!
0
 
LVL 1

Author Closing Comment

by:butterhook
ID: 40923937
We managed to manage the bug by working round it.
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question