Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:53:34+00:00 2026-05-30T09:53:34+00:00

Execution time to build a canvas pixel-by-pixel in GWT is extremely slow. For the

  • 0

Execution time to build a canvas pixel-by-pixel in GWT is extremely slow. For the following code, the 2D for loop with calls to “cpa.set(…)” is very slow.

...
RootPanel.get().add(canvas);
context = canvas.getContext2d();
ImageData id = context.createImageData(canvasWidth, canvasHeight);
CanvasPixelArray cpa = id.getData();

for (int y=0; y<canvasHeight; y++){
    for (int x=0; x<canvasWidth; x++){
        cpa.set(y*canvasWidth*4 + x*4 + 0,r);
        cpa.set(y*canvasWidth*4 + x*4 + 1,g);
        cpa.set(y*canvasWidth*4 + x*4 + 2,b);
        cpa.set(y*canvasWidth*4 + x*4 + 3,a);
    }
}           
context.putImageData(id, 0, 0); 

For example, with a 100×100 canvas, it takes 10 seconds. I’ve seen in some other javascript posts here showing that it may be more efficient to use a separate array buffer in the for loop, then just set the ImageData array equal to that buffer, but GWT doesn’t seem to allow that with CanvasPixelArray, you can only set a single pixel at a time in GWT, rather than copy an entire pixel array buffer into a CanvasPixelArray or ImageData.

Any ideas for efficient pixel manipulation with GWT canvas?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:53:35+00:00Added an answer on May 30, 2026 at 9:53 am

    Given that you have diagnosed your problem as Running in Devmode, I’ll detail some solutions here.

    First off, like Strelock commented, DevMode in Firefox is a good deal faster. Personally, I do all of my development in Firefox.

    Still, it sounds like Devmode will be unmanagable for you while developing/testing this. Your only option here is to compile. Thankfully, there are some parameters that we can tweak to speed it up, reducing it down to the 20 to 40 second mark assuming you have a project of decent size.

    Given a main com/foobar/MyApplication.gwt.xml file like so:

    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to="myapplication">
       ...
    </module>
    

    Lets create another, com/foobar/MyApplication-Firefox.gwt.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to='myapplication'>
       <inherits name='com.foobar.MyApplication'/>
       <!-- If you want to compile for a different browser, substitute this value. -->
       <set-property name="user.agent" value="gecko1_8"/>
    </module>
    

    Now when we compile, make sure to use the -draftCompile parameter. The compiled version may be a little less efficient, but it’ll compile down faster. If you are using the default build.xml file, you can add another target like so:

    <target name="gwtc-firefox" depends="javac" description="GWT compile to JavaScript (for FireFox)">
      <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
        <classpath>
          <pathelement location="src"/>
          <path refid="project.class.path"/>
          <pathelement location="${gwt.path}/validation-api-1.0.0.GA.jar" />
          <pathelement location="${gwt.path}/validation-api-1.0.0.GA-sources.jar" />
         </classpath>
        <jvmarg value="-Xmx256M"/>
        <arg line="-war"/>
        <arg value="war"/>
        <arg line="-draftCompile"/>
        <arg value="com.foobar.MyApplication-Firefox"/>
      </java>
    </target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is is possible to print the execution time of a shell command with following
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
i like to set timer for calculating execution time in c# for particular process
How do I get a method's execution time? Is there a Timer utility class
Is there any way to enable execution-time variable expansion for cmd.exe (normally done by
Is there a way to get the execution time of the last executed query
I want to calculate the execution time of my ASP.NET pages and display it
How do I completely disable the max-execution-time for scripts in flex? The configurable max
I'm trying to find a way to get the execution time of a section
I have noticed that regardless of a given script's execution time, every date() call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.