weird behavior with multiple CefBrowser objects

Having problems with building or using the JCEF Java binding? Ask your questions here.

weird behavior with multiple CefBrowser objects

Postby hien » Mon Nov 03, 2014 9:57 pm

I have a service that converts html content to PNG image. I am using a pool of CefBrowser to allow some parallelism in generating these images. What I have noticed is that the images I am generating are inconsistent with what I am rendering onto the browser. It appears that the images may be from another browser instance. Jcef didn't provide me with the functionality I need to generate images, but I have added that functionality by creating another implementation of CefBrowser with the onPaint() method as such

Code: Select all
   
@Override
    public void onPaint(CefBrowser browser,
                        boolean popup,
                        Rectangle[] dirtyRects,
                        ByteBuffer buffer,
                        int width,
                        int height) {
        this.buffer = buffer;
        this.lastOnPaintTimestampMillis = System.currentTimeMillis();
    }


After I received the onLoadEnd() event, I immediately read the buffer and generate my PNG image from data in that buffer. This works very well when I created a single instance of my browser, but this fails as soon as I started introducing more instances. I verified the CefBrowser argument passed into the onPaint() method to be the browser object I am looking at. Am I doing something fundamentally wrong? Thanks
hien
Newbie
 
Posts: 9
Joined: Mon Nov 03, 2014 9:38 pm

Re: weird behavior with multiple CefBrowser objects

Postby magreenblatt » Fri Nov 07, 2014 10:32 am

If it renders correctly to the multiple off-screen browser instances then it sounds like a problem somewhere in your usage of the |buffer| variable.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: weird behavior with multiple CefBrowser objects

Postby hien » Mon Nov 10, 2014 3:16 am

I decided to use the C++ CEF library instead of the java binding and I am receiving better results. However, I am still hitting an issue where the "final" OnPaint() event containing the pixel data for the whole page is extremely delayed. If I wait long enough (sometime a whole second), then I will eventually get it. Ideally I would like to know exactly when the final pixel buffer is painted. I have already received the OnLoadEnd() event. I can reproduce this easily in Java as well. This is with a single browser instance and 1 thread using it. I will ask this question in the regular CEF support forum since it would be more appropriate now that I am using the C++ library.
hien
Newbie
 
Posts: 9
Joined: Mon Nov 03, 2014 9:38 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 50 guests