Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » New JSON protocol doubled the traffic on GC/draw2d painting
New JSON protocol doubled the traffic on GC/draw2d painting [message #879208] Wed, 30 May 2012 14:56 Go to next message
Xihui Chen is currently offline Xihui Chen
Messages: 35
Registered: June 2011
Member
For example, the new JSON code for drawing a label is:

{
"meta": {
"requestCounter": 7421
},
"operations": [ [ "call", "gc55", "init", {
"height": 1036,
"font": [ [ "Verdana", "Lucida Sans", "Arial", "Helvetica", "sans-serif" ], 14, false, false ],
"width": 1586,
"fillStyle": [ 240, 240, 240, 255 ],
"strokeStyle": [ 74, 74, 74, 255 ]
} ], [ "call", "gc55", "draw", {
"operations": [ [ "beginPath" ], [ "rect", 0.0, 0.0, 1586.0, 1036.0 ], [ "fill" ], [ "beginPath" ], [ "rect", 0.0, 0.0, 1586.0, 1036.0 ], [ "fill" ], [ "fillStyle", [ 183, 239, 251, 255 ] ], [ "beginPath" ], [ "rect", 339.0, 727.0, 198.0, 35.0 ], [ "fill" ], [ "strokeStyle", [ 0, 0, 0, 255 ] ], [ "strokeText", "4.775 a.u.", false, true, true, 341.0, 735.0 ], [ "strokeStyle", [ 255, 0, 0, 255 ] ], [ "lineWidth", 2 ], [ "beginPath" ], [ "rect", 340.0, 728.0, 196.0, 33.0 ], [ "stroke" ] ]
} ], [ "call", "w1", "measureStrings", {
"strings": [ [ -746581837, "4.775 a.u.", [ "Verdana", "Lucida Sans", "Arial", "Helvetica", "sans-serif" ], 14, false, false, -1, false ] ]
} ] ]
}

The old protocol is:

var req = org.eclipse.swt.Request.getInstance();req.setRequestCounter( "30" );var wm = org.eclipse.swt.WidgetManager.getInstance();var w = wm.findWidgetById( "w34" );var gc = w.getGC();gc.init( 1444, 1003, "12px Verdana, 'Lucida Sans', Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );gc.drawRectangle( 0, 0, 1444, 1003, true );gc.setProperty( "background", "#90ee90" );gc.drawRectangle( 20, 32, 116, 20, true );gc.setProperty( "foreground", "#000000" );gc.setProperty( "font", "10px Verdana" );gc.drawText( "79,261.000 a.u.", 37, 36, false );gc.setProperty( "foreground", "#ff8000" );gc.setProperty( "lineWidth", 2 );gc.drawRectangle( 21, 33, 114, 18, false );

The new JSON protocol has 977 characters and old protocol has 666 characters. It looks like the new protocol transferred more information than old protocol. And it unnecessarily format integer to 123.0. I'm not sure if it is due to the upgrade on draw2d/GEF or simply because of JSON format. Is that possible to simplify the JSON format?

[Updated on: Wed, 30 May 2012 14:57]

Report message to a moderator

Re: New JSON protocol doubled the traffic on draw2d painting [message #879459 is a reply to message #879208] Thu, 31 May 2012 05:05 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim Buschtoens
Messages: 379
Registered: July 2009
Senior Member
Hi.

> The new JSON protocol has 977 characters and old protocol has 666

Okay, so a few notes:
a) This would not be doubled, its about 150% (double would be 200%).
b) Your examples do not do the same thing, the JS output uses less font
names and does no text measurement. If you take that into account,
its much nearer to parity.
c) If you also take the http-compression of the response into account,
its debatable which is longer.

Yes, the new protocol may be a bit longer in same cases for GC. But we
knowingly accepted that. The reason is that the new protocol is much
closer to the html5-canvas syntax, which gives as several advantages for
future development and maintenance.

I hope that clears that up.

Greetings,
Tim

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: New JSON protocol doubled the traffic on draw2d painting [message #879622 is a reply to message #879459] Thu, 31 May 2012 10:33 Go to previous messageGo to next message
Xihui Chen is currently offline Xihui Chen
Messages: 35
Registered: June 2011
Member
Hi Tim,

Thank you for explaining that! Yes, the example I posted here is 150%, but for complicated draw2D widgets as in attached screenshot, it is about 200%. Its traffic is around 650KB/S on RAP 1.4.1 and 1.3MB/S on RAP 1.5M7. I also attached the message details. With http compression, the text message can be compressed to 6:1, so the traffic could not be a big problem. If the new protocol is more efficient for client to parse, it may get a better performance overall. I didn't mean to criticize the new protocol. I know it has lots of advantages. I just hope it can be improved to have a shorter length. For example, removing all white spaces could save about 1/5 length.

Thanks,
Xihui

[Updated on: Thu, 31 May 2012 14:39]

Report message to a moderator

Re: New JSON protocol doubled the traffic on draw2d painting [message #880297 is a reply to message #879622] Fri, 01 June 2012 15:45 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1290
Registered: July 2009
Senior Member

Hi Xihui,

I'm totally stunned by what you're doing with the *experimental* GEF
component. Looking at your example, this rendering involves 15,686 (!)
GC operations. You're not only drawing charts, you also draw your
toolbar and buttons, don't you?

We have always pointed out that a high performance Draw2D for RAP is
possible, but it requires a different implementation that bypasses the
SWT API and directly passes vector data to the client GC. This is not a
simple task, it will probably involve months of work.

The current GEF component in the RAP Incubator is not designed for this
ammount of data. If it works for you, you're lucky, but the problem with
your approach is not the protocol. It's the amount of GC operations
needed to draw these charts.

Regards, Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: New JSON protocol doubled the traffic on draw2d painting [message #881466 is a reply to message #880297] Mon, 04 June 2012 11:55 Go to previous message
Xihui Chen is currently offline Xihui Chen
Messages: 35
Registered: June 2011
Member
Thank you Ralf! Yes, it has too large amount of GC operations. I will find an alternative way to use native or HTML5 canvas widgets.

Best regards,
Xihui
Previous Topic:Toolitem of vetical toolbar are centered per default in 1.5
Next Topic:Styling height of view tab folder
Goto Forum:
  


Current Time: Sat Jul 26 05:15:46 EDT 2014

Powered by FUDForum. Page generated in 0.02301 seconds