Invalid 1 user view causes all user views in the view group to be invalidated?

I have a custom viewing group. There are several user views in this user view group. Custom views all overlap in the layout.

Overlapping views make sense to create β€œlayers”. This way, one layer can create some static content, but another layered view creates different animated content. The problem occurs when I call .postInvalidate from another thread on one view, which is basically an animation that runs at 60FPS. Outside of multi-layer representations, 60FPS is available for the device I am using (Galaxy S3).

Within this custom view group, .invalidate causes 1 out of 2 hardware rendered views to be invalidated, and some types of software are invalidated 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] 
+8
android android-layout android-canvas android-custom-view
source share
1 answer

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

Of course, you can check the value of HardwareRenderer.RENDER_DIRTY_REGIONS on your device in this application.

+1
source share

All Articles