5

I'm using page curl animation created by Harism at https://github.com/harism/android_page_curl‎ .I have implemented his animation to my e-book reader app for android and the problem is when I swipe pages fastly, sometimes strange white lightening is switched. However when I curl pages normally there is not such situation. I think the problem is on OpenGL side.I'm not familiar with that technology but in debugging process I see that after page curl finished there is still some drawing process is going on CurlRenderer class at onDrawFrame method.

    @Override
    public synchronized void onDrawFrame(final GL10 gl) {
        mObserver.onDrawFrame();
        gl.glClearColor(Color.red(mBackgroundColor) / 255f,
                Color.green(mBackgroundColor) / 255f,
                Color.blue(mBackgroundColor) / 255f,
                Color.alpha(mBackgroundColor) / 255f);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        gl.glLoadIdentity();
        if (USE_PERSPECTIVE_PROJECTION) {
            gl.glTranslatef(0, 0, -6f);
        }
        for (int i = 0; i < mCurlMeshes.size(); ++i) {

            mCurlMeshes.get(i).onDrawFrame(gl);
        }
        Calendar now = Calendar.getInstance();
        int minute = now.get(Calendar.MINUTE);
        int second = now.get(Calendar.SECOND);
        int millis = now.get(Calendar.MILLISECOND);
        Log.i("time curl renderer (onDrawFrame) : ", minute + ":" + second + "." + millis);
    }

Below is the log

02-20 07:27:37.320  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.326
02-20 07:27:37.328  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.336
02-20 07:27:37.335  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.344
02-20 07:27:37.343  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.354
02-20 07:27:37.359  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.367
02-20 07:27:37.367  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.377
02-20 07:27:37.375  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.387
02-20 07:27:37.390  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.399
02-20 07:27:37.398  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.410
02-20 07:27:37.414  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.422
02-20 07:27:37.421  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.432
02-20 07:27:37.437  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.444
02-20 07:27:37.445  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.455
02-20 07:27:37.453  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.465
02-20 07:27:37.468  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.477
02-20 07:27:37.476  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.487
02-20 07:27:37.492  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.501
02-20 07:27:37.500  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.509
02-20 07:27:37.515  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.520
02-20 07:27:37.523  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.532
02-20 07:27:37.531  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.542
02-20 07:27:37.546  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.555
02-20 07:27:37.554  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.565
02-20 07:27:37.570  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.576
02-20 07:27:37.578  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.588
02-20 07:27:37.585  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.598
02-20 07:27:37.601  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.610
02-20 07:27:37.609  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.619
02-20 07:27:37.617  30215-30407/org.com.ebook I/time curl renderer (onDrawFrame) :﹕ 27:37.629 

book's page finishes curling when first line of log appears let's say 02-20 07:27:37.320 at this situation, but on the next lines you can see that onDrawFrame method is called continuosly.Maybe I'm curling pages when this method do not finished it's work yet and lightening switch coming from that fault? Any help?Here is the link of video you can see there that lightening appears sometimes http://www.youtube.com/watch?v=HPJ2U18Caok&feature=youtu.be

support_ms
  • 1,873
  • 1
  • 18
  • 33
  • Hi, would you post the video as well? From this, it is hard to guess what's wrong. Also, what mobile device do you test on? Did you try on multiple devices? – the swine Feb 20 '14 at 08:08
  • Yes I tried some devices, the problem is not going.I will try to post video as well... – support_ms Feb 20 '14 at 08:48
  • I see. And the effect that you refer to is when the whole screen turns grey, or when you see bright part of the page on the left? Can you also show us how you are calling the curl from tap/slide event hnadler? – the swine Feb 20 '14 at 11:40
  • I refer to when whole screen turns grey.I did not get your second question? As I understand there is method on CurlView class which handles onTouch event – support_ms Feb 20 '14 at 12:23
  • Oh, ok, I was confused as the code you posted seemed to me to be your application code. But it is just the modified curl code. – the swine Feb 20 '14 at 12:55
  • 1
    I suggest that you compile and run the curl example project without any additions or modifications to see if this happens there as well. If so, it is a bug in curl. If not, we will take it from there. – the swine Feb 20 '14 at 12:58
  • Ok I will do as you said. – support_ms Feb 20 '14 at 13:01
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/47955/discussion-between-the-swine-and-support-ms) – the swine Feb 20 '14 at 13:10
  • 2
    I see from the log that some onDrawFrame calls actually return after the next one starts(compare timings from the 2 and 3 log entry for example). I think there might be some sort of multithreading/sync issue involved here. – Pavel Beliy Feb 20 '14 at 15:19
  • @PavelBeliy Nicely spotted! Yes, that might be an issue, although on desktop, it is common to have several pre-rendered frames in the queue, thanks to the asynchronous operation model OpenGL has. It can also be asynchronous event handling in Android. In Java, thread safety is handled easily by using the keyword 'synchronized', it should be quite simple to force a lock on the curl object and see what happens (i can imagine the thread rendering the next frame damaging the page curl meshes the thread from the previous frame is using). That could fix the issue. – the swine Feb 21 '14 at 13:03
  • @the swine Did you see project code? There are synchronized methods. Where we can change to fix the issue? – support_ms Feb 21 '14 at 14:02
  • If there are synchronized methods, it should never happen that the timestamps overlap. Find out how they overlap and use `synchronized` or a lock object to avoid that. – the swine Feb 21 '14 at 15:53
  • @support_ms youtube video shows you are running in 2.3 emulator ! did you get same lightning in device (may be 4.0 + devices) ? – LOG_TAG Jun 09 '14 at 04:46
  • 1
    @LOG_TAG Yes, it is appearing in all devices. – support_ms Jun 09 '14 at 04:50
  • @support_ms have you checked when GC called? may be the logic will result in GC frequently(about once per 3 second ) may be? – LOG_TAG Jun 09 '14 at 05:22
  • I don't know how works OpenGL.In my project I just implemented that page curl module. I 'll be glad if you would check that and detect problem – support_ms Jun 09 '14 at 05:41

1 Answers1

0

Other possible solutions:

Try to use Render Script Page curl !

enter image description here

( Renderscript is a language, API, and runtime library that you can use to achieve high performance rendering and computation for Android applications. refer you to Jason Sams's introductory articles, Introducing Renderscript and Renderscript Part 2.)

Also have a look at this Awesome page curl lib with Page Turner!

More Sources:

http://www.zeropointnine.com/blog/3d-page-curl-effect-updated/

http://www.doubleencore.com/2013/10/renderscript-for-all/

LOG_TAG
  • 19,894
  • 12
  • 72
  • 105