Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalidating 1 Custom View Causes All Custom Views In A View Group To Be Invalidated?

I have a custom view group. In that custom view group are a number of custom views. The custom views all overlap each other in layout.

The overlapping views are intential to create "layers". So one layer may create some static content, but another layered view creates different animated content. Problem comes when I call .postInvalidate from another thread on one view that basically is an animation that runs at 60FPS. Outside of the layered views 60FPS is achievable for the device I'm using (Galaxy S3).

Inside this custom view group, .invalidate causes 1 out of the 2 hardware rendered views to invalidate, and some of the software views to invalidate with it.

MyCustomViewThatShouldNotInvalidate(AbstractDialLayer).onDraw(Canvas) line: 68    
MyCustomViewThatShouldNotInvalidate.onDraw(Canvas) line: 79    
MyCustomViewThatShouldNotInvalidate(View).draw(Canvas) line: 13650    
MyCustomViewThatShouldNotInvalidate(View).draw(Canvas, ViewGroup, long) line: 13534    
MyCustomViewGroup(ViewGroup).drawChild(Canvas, View, long) line: 2938    
MyCustomViewGroup(ViewGroup).dispatchDraw(Canvas) line: 2808    
MyCustomViewGroup(View).buildDrawingCache(boolean) line: 12909    
MyCustomViewGroup(View).getDisplayList(DisplayList, boolean) line: 12580    
MyCustomViewGroup(View).getDisplayList() line: 12645
RelativeLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
RelativeLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
RelativeLayout(View).getDisplayList() line: 12645    
RelativeLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
RelativeLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
RelativeLayout(View).getDisplayList() line: 12645    
NoSaveStateFrameLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
NoSaveStateFrameLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
NoSaveStateFrameLayout(View).getDisplayList() line: 12645    
ViewPager(ViewGroup).dispatchGetDisplayList() line: 2920    
ViewPager(View).getDisplayList(DisplayList, boolean) line: 12537    
ViewPager(View).getDisplayList() line: 12645    
LinearLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
LinearLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
LinearLayout(View).getDisplayList() line: 12645    
RelativeLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
RelativeLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
RelativeLayout(View).getDisplayList() line: 12645    
NoSaveStateFrameLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
NoSaveStateFrameLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
NoSaveStateFrameLayout(View).getDisplayList() line: 12645    
LinearLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
LinearLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
LinearLayout(View).getDisplayList() line: 12645    
LongPressGestureDetectingFrameLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
LongPressGestureDetectingFrameLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
LongPressGestureDetectingFrameLayout(View).getDisplayList() line: 12645    
FrameLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
FrameLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
FrameLayout(View).getDisplayList() line: 12645    
LinearLayout(ViewGroup).dispatchGetDisplayList() line: 2920    
LinearLayout(View).getDisplayList(DisplayList, boolean) line: 12537    
LinearLayout(View).getDisplayList() line: 12645    
CustomViewAbove(ViewGroup).dispatchGetDisplayList() line: 2920    
CustomViewAbove(View).getDisplayList(DisplayList, boolean) line: 12537    
CustomViewAbove(View).getDisplayList() line: 12645    
SlidingMenu(ViewGroup).dispatchGetDisplayList() line: 2920    
SlidingMenu(View).getDisplayList(DisplayList, boolean) line: 12537    
SlidingMenu(View).getDisplayList() line: 12645    
PhoneWindow$DecorView(ViewGroup).dispatchGetDisplayList() line: 2920    
PhoneWindow$DecorView(View).getDisplayList(DisplayList, boolean) line: 12537    
PhoneWindow$DecorView(View).getDisplayList() line: 12645    
HardwareRenderer$Gl20Renderer(HardwareRenderer$GlRenderer).draw(View, View$AttachInfo,         HardwareRenderer$HardwareDrawCallbacks, Rect) line: 1170    
ViewRootImpl.draw(boolean) line: 2275    
ViewRootImpl.performDraw() line: 2147    
ViewRootImpl.performTraversals() line: 1958    
ViewRootImpl.doTraversal() line: 1112    
ViewRootImpl$TraversalRunnable.run() line: 4474    
Choreographer$CallbackRecord.run(long) line: 725    
Choreographer.doCallbacks(int, long) line: 555    
Choreographer.doFrame(long, int) line: 525    
Choreographer$FrameDisplayEventReceiver.run() line: 711    
Handler.handleCallback(Message) line: 615    
Choreographer$FrameHandler(Handler).dispatchMessage(Message) line: 92    
Looper.loop() line: 137    
ActivityThread.main(String[]) line: 4918    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not         available [native method]    
Method.invoke(Object, Object...) line: 511    
ZygoteInit$MethodAndArgsCaller.run() line: 1004    
ZygoteInit.main(String[]) line: 771    
NativeStart.main(String[]) line: not available [native method]    
like image 983
McNinja Avatar asked Apr 14 '14 13:04

McNinja


1 Answers

Invalidate on a view will chain the invalidate calls to its parents in the view hierarchy. If this is hardware accelerated, it may just invalidate everything depending on a flag in HardwareRenderer class. This is an optimization. You can check the invalidate implementation. Here is a link to the relevant call - Invalidate() -check for hardware acceleration

To be sure, you can check the value of HardwareRenderer.RENDER_DIRTY_REGIONS on your device in that application.

like image 126
Aniket Awati Avatar answered Jan 05 '23 02:01

Aniket Awati