Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323080

Summary: [GC] font property is rendered multiple times under certain constellation
Product: [RT] RAP Reporter: Ivan Furnadjiev <ivan>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: christian.campo, elias
Version: 1.3   
Target Milestone: 1.4 M2   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 322697    
Attachments:
Description Flags
Test case
none
Patch to solve the problem none

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.