android-flip
android-flip copied to clipboard
Bug: Invalidate View Problem in Galaxy S3
Hello. First thank you for library, its really great. While I'm developing an application I came across a bug in Galaxy S3 phones. While flipping the view invalidates itself and causes black screen. This bug can be seen at the demo also. I uploaded a video on you ube about this bug. You can check it. Thank you in advance. http://www.youtube.com/watch?v=rv0pLLCn-8w
Hi. Library is superb. But i am also facing the same view invalidating issue as @cagkanciloglu . I tested in galaxy note and galaxy note 2. Could anyone please help how to solve this. Thank you in advance..
I'll try to get a Samsung device to reproduce the issue.
Could you tell me the OS version on your devices?
Thanks
Hi guys, I guess the problem is while taking screenshot in grabIt.java file in higher resolution mobiles previous screenshot is released to free memory. So i think we need to reduce the size of bitmap created or compress bitmap for high res mobiles alone. Please correct me if i am wrong. Thank you.
Note is android 4.0.4 and Note II is android 4.1.1. But I guess this problem may occur for most of the high resolution devices.
Thanks
Aravind's theory may be correct. I also tested it on Galaxy S2 its working alright. Btw OS version on my S3 is 4.1.1
Flip Complex Layouts demo working alright on S3. Fyi
I tested on emulator running OS 4.1 with high resolution settings (720 x 1280), but I failed to reproduce it.
It doesn't sound like a memory issue as far as I can tell from the video. But I could be wrong on this.
I'll ask my friends for a Galaxy Note for further testing.
By the way, could you try to pause and resume the activity to see what happens then, by pressing the Home button?
Nothing happened after resuming the activity. Issue remained.
Nothing changes while pausing and resuming activity. I will attach my log data printed for a single flip while running in galaxy Note
11-06 14:45:53.329: D/OpenAphid(30218): flippedToView: 4
11-06 14:45:53.329: D/OpenAphid(30218): bufferedViews: [android.widget.RelativeLayout@41c99f18, android.widget.RelativeLayout@419ee2a0, android.widget.RelativeLayout@41c64270], index: 1
11-06 14:45:53.369: D/dalvikvm(30218): GC_FOR_ALLOC freed 8011K, 34% free 38951K/58311K, paused 21ms
11-06 14:45:53.374: I/dalvikvm-heap(30218): Grow heap (frag case) to 41.049MB for 2457616-byte allocation
11-06 14:45:53.399: D/dalvikvm(30218): GC_FOR_ALLOC freed <1K, 30% free 41350K/58311K, paused 14ms
11-06 14:45:53.439: D/dalvikvm(30218): GC_CONCURRENT freed 0K, 30% free 41351K/58311K, paused 1ms+2ms
11-06 14:45:53.459: I/OpenAphid(30218): Update visible views, index -1, buffered: 3
11-06 14:45:53.459: D/OpenAphid(30218): bufferedViews: [android.widget.RelativeLayout@41948060, android.widget.RelativeLayout@41c99f18, android.widget.RelativeLayout@419ee2a0], index: 1
11-06 14:45:53.469: I/OpenAphid(30218): Update visible views, index -1, buffered: 3
11-06 14:45:53.469: D/OpenAphid(30218): flippedToView: 4
11-06 14:45:53.469: D/OpenAphid(30218): bufferedViews: [android.widget.RelativeLayout@41948060, android.widget.RelativeLayout@41c99f18, android.widget.RelativeLayout@419ee2a0], index: 1
11-06 14:45:53.489: I/OpenAphid(30218): Update visible views, index -1, buffered: 3
11-06 14:45:53.489: D/OpenAphid(30218): bufferedViews: [android.widget.RelativeLayout@4199a880, android.widget.RelativeLayout@421aeed8, android.widget.RelativeLayout@419ee2a0], index: 1
11-06 14:45:53.489: D/OpenAphid(30218): flippedToView: 4
11-06 14:45:53.489: D/OpenAphid(30218): bufferedViews: [android.widget.RelativeLayout@4199a880, android.widget.RelativeLayout@421aeed8, android.widget.RelativeLayout@419ee2a0], index: 1
11-06 14:45:53.504: I/OpenAphid(30218): Update visible views, index -1, buffered: 3
11-06 14:45:53.504: D/OpenAphid(30218): bufferedViews: [android.widget.RelativeLayout@4215ede8, android.widget.RelativeLayout@419ad6c8, android.widget.RelativeLayout@419ee2a0], index: 1
11-06 14:45:53.509: D/OpenAphid(30218): onLayout: 0, 0, 800, 1280; child 3
11-06 14:45:53.529: D/dalvikvm(30218): GC_FOR_ALLOC freed 634K, 30% free 40873K/58311K, paused 17ms
11-06 14:45:53.529: I/dalvikvm-heap(30218): Grow heap (frag case) to 44.490MB for 4096016-byte allocation
11-06 14:45:53.564: D/dalvikvm(30218): GC_CONCURRENT freed 2489K, 28% free 42384K/58311K, paused 1ms+3ms
11-06 14:45:53.609: D/OpenAphid(30218): create bitmap 800x1280
11-06 14:45:53.609: D/OpenAphid(30218): reloading texture: android.widget.RelativeLayout@419ad6c8 and android.widget.RelativeLayout@419ee2a0; old views: android.widget.RelativeLayout@419ad6c8, android.widget.RelativeLayout@419ee2a0, front changed true, back changed false
11-06 14:45:53.609: D/OpenAphid(30218): Destroy texture: 2
11-06 14:45:53.609: D/OpenAphid(30218): createTexture: 800, 1280; POT: 1024, 2048
11-06 14:45:54.119: I/OpenAphid(30218): Update visible views, index 1, buffered: 3
But for galaxy S2 my logacat data are
11-06 15:02:52.193: I/OpenAphid(17658): Update visible views, index -1, buffered: 2
11-06 15:02:53.213: D/OpenAphid(17658): flippedToView: 1
11-06 15:02:53.213: D/OpenAphid(17658): bufferedViews: [android.widget.RelativeLayout@2fdac120, android.widget.RelativeLayout@2fd78728], index: 0
11-06 15:02:53.733: I/OpenAphid(17658): Update visible views, index -1, buffered: 3
11-06 15:02:53.733: D/OpenAphid(17658): bufferedViews: [android.widget.RelativeLayout@2fdac120, android.widget.RelativeLayout@2fd78728, android.widget.RelativeLayout@2fdd5050], index: 1
11-06 15:02:53.733: I/OpenAphid(17658): Update visible views, index 1, buffered: 3
11-06 15:02:53.733: D/OpenAphid(17658): onLayout: 0, 0, 480, 800; child 3
11-06 15:02:53.813: D/OpenAphid(17658): create bitmap 480x800
11-06 15:02:53.813: D/OpenAphid(17658): reloading texture: android.widget.RelativeLayout@2fd78728 and android.widget.RelativeLayout@2fdd5050; old views: android.widget.RelativeLayout@2fd78728, android.widget.RelativeLayout@2fdd5050, front changed false, back changed true
11-06 15:02:53.813: D/OpenAphid(17658): Destroy texture: 1
11-06 15:02:53.813: D/OpenAphid(17658): createTexture: 480, 800; POT: 512, 1024
You can notice that memory is freed before creating second bitmap for Galaxy note where as it is not in S II. So i guessed that issue is with the size of bitmap. I am sorry if i am wrong.
Thanks for the detailed report. The GC logs are fine for this scenario.
I guess the bug could be caused by some incorrect OpenGL renderer settings for the high resolution. I'll dig into it for more clues
Thanks. I am eager for your solution....
No luck?
I'm still struggling to reproduce the bug. I went to a Samsung store and tried a GS3 and a Galaxy Note II with the demo app, but found nothing abnormal.
One user suggested that the problem is easy to reproduce for certain layout hierarchy. If anyone knows a layout pattern for this issue, please share it to us. Thanks for advance.
The layout below is similar to the layout in the video. I hope this helps.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/FrameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/gallery_flip_item_background_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/galeritestimage" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="bottom"
android:background="@color/transparentBlack"
android:padding="5dp" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/feed_taggeduser_image" />
<TextView
android:id="@+id/gallery_flip_item_place_name_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:maxLines="2"
android:text="Merve B (Gezgin): "Big Chefs'te Big Burger yedim ve gerçekten adını hak edecek kadar büyüktu :) Merve B (Gezgin): "Big Chefs'te Big Burger yedim ve gerçekten adını hak edecek kadar büyüktu :)"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/gallery_flip_item_place_linearlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@color/transparentBlack"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:id="@+id/gallery_flip_item_place_icon_imageview"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="3dp"
android:scaleType="fitXY"
android:src="@drawable/img1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/gallery_flip_item_place_name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Rumeli Hısarı İskele Restaurant"
android:textColor="@color/white"
android:textSize="19sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/feed_checkin_location" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/gallery_flip_item_place_district_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mercan"
android:textColor="@color/white"
android:textSize="11sp" />
<TextView
android:id="@+id/gallery_flip_item_place_city_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="İstanbul"
android:textColor="@color/white"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
@cagkanciloglu I setup an activity to implement the layout that is supposed to cause issues. Unfortunately, it still runs fine on my new Nexus 7, old Defy+ and emulator.
@openaphid I will implement the problematic layout and share its apk and source as soon as possible.
@cagkanciloglu Thanks. It would be the best way for me to fix the issue.
https://github.com/cagkanciloglu/FlipViewProblematicLayout
Here is the link for the problematic layout. I shot a new video about the problem too, you can find it in "video" folder.
I guess I got the problem: it seems it happens when application downloads image for background. After the download when I begin the gesture for flipping, the background image is being released immediately. Maybe you can add a listener so when the gesture ends you release the image. That should do the trick.
Sorry for my late reply.
It seems that FlipView doesn't work well with async content. I'll try to figure out a way to improve it in develop branch first
The same phenomenon occurs in my program has been. My device Galaxy Notes 2 and OS version is 4.1.2. the Galaxy S3 is the same phenomenon occurs.
Until now, the results of testing the devices except the device Galaxy Notes 2 and Galaxy S3, the problem did not occur.
Ironically Demo apk 2 and Galaxy Note Galaxy S3 has been working well.
Please help me.
The layout is the same symptoms that occurred. Download images asynchronously using a thread.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:orientation="vertical" >
<RelativeLayout
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center|left"
android:background="@color/white"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" >
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="홍보관"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/black"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/backlay"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:clickable="true"
android:gravity="center|left" >
<Button
android:id="@+id/backbtn"
android:layout_width="20dp"
android:layout_height="25dp"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_marginLeft="10dp"
android:background="@drawable/backbtnpress" />
</LinearLayout>
<LinearLayout
android:id="@+id/spnlay"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:clickable="true"
android:gravity="center|right" >
<Button
android:id="@+id/spnbtn"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginRight="10dp"
android:background="@drawable/spnbtnpress" />
</LinearLayout>
<ImageView
android:id="@+id/bgline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/bg_line" />
</RelativeLayout>
<ImageView
android:id="@+id/photop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="10"
android:clickable="true"
android:scaleType="centerCrop"
android:src="@drawable/loading_img_big" />
<ImageView
android:id="@+id/bgline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/bg_line" />
<TextView
android:id="@+id/titlep"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center|left"
android:layout_marginLeft="10dp"
android:gravity="center|left"
android:singleLine="true"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textColor="@android:color/black"
android:textStyle="bold" />
<ImageView
android:id="@+id/bgline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/bg_line" />
<TextView
android:id="@+id/descriptionp"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:textColor="@android:color/black" />
@KyungHo if you met the same problem as @cagkanciloglu showed in http://www.youtube.com/watch?v=rv0pLLCn-8w . I doubt it could be caused by the OpenGL lighting setup in FlipView. But it's hard for me to debug it as it can't be reproduced on my devices (Defy+ and Nexus 7)
@cagkanciloglu the issue you found in your followup video. It's actually a new issue, which will be resolved by fixing #37 and #28
@cagkanciloglu I migrated your project into the demo app as "Issue #5". I found that its async loading logic is not 100% correct. Please refer to the comments in my commit for more details: https://github.com/openaphid/android-flip/blob/bef17096d3eef18f412916b3c928ca81438c498f/FlipView/Demo/src/com/aphidmobile/flip/demo/issue5/GalleryFlipItem.java
You can also download the updated APK: https://github.com/openaphid/android-flip/blob/develop/FlipView/Demo/APK/Aphid-FlipView-Demo.apk
BTW: I also found the layout hierarchy is not optimal, you can try to improve it if it's used in your real app.
i am download your project and importing into my project and it sow errors "R.styleable.FlipViewController_orientation" R.styleable.FlipViewController_animationBitmapFormat is cannt resloved
@openaphid We solved the black screen render error on Samsung Galaxy S III device, changing the gluPerspective far plane to a higher number. In FlipRenderer.java, onSurfaceChange method:
float fovy = 20f;
float eyeZ = height / 2f / (float) Math.tan(TextureUtils.d2r(fovy / 2));
GLU.gluPerspective(gl, fovy, (float) width / (float) height, 0.5f, 5000); //We changed Math.max(2500.0f, eyeZ) to 5000
@ZoserLock Thanks a lot. I will merge it into master branch later.
I've pushed a fix into develop branch.
Could you guys test it on a Galaxy S3 for me please? APK: https://github.com/openaphid/android-flip/tree/develop/FlipView/Demo/APK
But I still don't get the real reason of the issue. If eyeZ is larger than 2500, zFar should be correctly set to eyeZ by Math.max, which is the case on my Nexus 7. Maybe it's caused by a math rounding issue on certain OpenGL drivers.
Yep. Setting the value to 5000 solved that issue. But after I have implemented the solution I noticed another bug on S3. While I was sliding through the pages I saw some pages coming full white at first then the actual layout. I don't think It's caused by async content because the page comes with complete white other than this I have high speed internet connection. I shot a video about the bug. It's rather short video but you can see the bug. And sorry for the quality.
http://www.youtube.com/watch?v=v5XTKueIIKY
And the layout is almost similar to one you looked early. I just took your relative layout advice and changed view and added cache code for the content image downloader. I can send the layout xml and the Flip Item class too if you want.
The full white issue seems not related to async content. Please share your code that can reproduce the problem.
Is it reproducible on emulator? And what happens if you hold the page when it's full white?