Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323080 - [GC] font property is rendered multiple times under certain constellation
Summary: [GC] font property is rendered multiple times under certain constellation
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.4 M2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 322697
  Show dependency tree
 
Reported: 2010-08-18 15:20 EDT by Ivan Furnadjiev CLA
Modified: 2010-08-20 02:51 EDT (History)
2 users (show)

See Also:


Attachments
Test case (1.10 KB, text/plain)
2010-08-19 02:04 EDT, Ivan Furnadjiev CLA
no flags Details
Patch to solve the problem (4.29 KB, patch)
2010-08-19 02:14 EDT, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Furnadjiev CLA 2010-08-18 15:20:35 EDT
If you use GC to measure the text dimension (usually in computeSize), font property is rendered multiple times to the client.
Comment 1 Ivan Furnadjiev CLA 2010-08-19 02:04:37 EDT
Created attachment 176962 [details]
Test case

This issue has been observed in Riena, running on top of RAP. Riena uses a pattern like:
----
GC gc = new GC( this );
gc.setFont( font );
FontMetrics metrics = gc.getFontMetrics();
....
do some calculations
....
gc.dispose();
----
in their SWT computeSize or similar methods, which leads to sequence of equals SetFont operations in GCAdapter#gcOperations list. As a result, javascript code gc.setProperty( "font", "..." ) has been rendered multiple times. In Riena SWT example application I count 290 usless
set font renderings in every request/response, which increases the size of rendered javascript a lot.
Comment 2 Ivan Furnadjiev CLA 2010-08-19 02:14:27 EDT
Created attachment 176963 [details]
Patch to solve the problem

Add new SetFont operation to the list with gc operations (GCAdapter#addOperation) only if the font of last SetFont operation differ.
Comment 3 Ivan Furnadjiev CLA 2010-08-19 02:25:44 EDT
Apply patch to CVS HEAD. As a result of the patch, the number of gc.setProperty( "font", "..." ) renderings in Riena SWT Example App has been reduced from 290 to 12 and the size of request/response data from 40k to 10k. This reduced the browser CPU usage 3 times as well.
Comment 4 Elias Volanakis CLA 2010-08-19 14:33:32 EDT
Cool! Thanks!
Comment 5 Ivan Furnadjiev CLA 2010-08-20 02:51:00 EDT
Fixed in a different way with bug 323116.