DSAppTeam / PanelSwitchHelper

:heavy_check_mark: A framework that helps the keyboard smoothly transition to the function panel 一个帮助键盘平稳过渡到功能面板的框架,支持动画无缝衔接,支持 activity/fragment/dialog/dialogFragment/popupWindow 容器,支持IM/直播/视频播放/信息流评论等场景,支持全屏模式。
Apache License 2.0
2.38k stars 284 forks source link

键盘弹起动画卡顿 #110

Closed a154225859 closed 3 years ago

a154225859 commented 3 years ago

Androidx版本:是 PanelSwitchHelper版本:v1.3.11 手机型号: 三星S10 手机系统版本: Android 10 [在直播语聊房布局控件比较多的场景,输入法弹起上移时动画卡顿,收起下移时不卡

2020-11-16 20:48:32.404 27146-27146/in.dradhanus.liveher D/LogTracker: PanelSwitchLayout(74649917)#onLayout => 界面每一次 layout 的信息回调 layoutInfo = onLayout(changed : false , l : 0 , t : 0 , r : 1080 , b : 2280) currentPanelState = 显示键盘输入 isPad = false isFullScreen = false isPortrait = true isNavigationShown = false screenH (static,include SystemUI) = 2280 screenH (static,exclude SystemUI) = 2168 screenH (dynamic,exclude SystemUI) = 1182 localLocation[y] = 0 toolbarH = 0 StatusBarH = 112 NavigationBarH = 0 layout Location = (0,0) paddingTop = 0 keyboardH = 986 ContentContainerTop = -986 ContentContainerH = 2280 PanelContainerTop = 1294 PanelContainerH = 986 changeBounds = false contentContainer Layout = (0,-986,1080,1294) panelContainer Layout = (0,1294,1080,2280) 2020-11-16 20:48:32.405 27146-27146/in.dradhanus.liveher D/LogTracker: PanelSwitchLayout(74649917)#onGlobalLayout => 界面每一次变化的信息回调 windowSoftInputMode = 19 currentPanelSwitchLayoutVisible = true screenHeight = 2280 contentHeight = 1182 isFullScreen = false isNavigationBarShown = false deviceStatusBarH = 112 deviceNavigationBarH = 0 systemInset = left(112) top(0) right(0) bottom(986) inset = left(0) top(112) right(0) bottom(0) currentSystemInfo = statusBarH : 112, navigationBarH : 0 全面屏手势虚拟栏H : 0 currentSystemH = 112 minLimitCloseKeyboardH = 0 minLimitOpenKeyboardH = 300 lastKeyboardH = 986 currentKeyboardInfo = keyboardH : 986, realKeyboardH : 986, isShown : true

尝试把ui移到demo里 也有卡顿的情况 可以直接替换PhoneDouyinLiveActivity的布局测试 https://raw.githubusercontent.com/a154225859/demo/main/activity_douyin_live_layout.xml

a154225859 commented 3 years ago

https://github.com/a154225859/demo/blob/main/DB730B552BFB344E7FC25A089FD10C77.mp4 这是录屏

YummyLau commented 3 years ago

看了下你的布局虽然复杂,但是框架的滑动并不会引起布你复杂布局内部的调整。这个得看你的布局及activity逻辑怎么写。 目前也有直播/语音房间的app也用了这个库,如果方便的话,可以上传下你的Demo这个页面的代码,我定位下,上述的log无法直观反映问题。 @a154225859

a154225859 commented 3 years ago

看了下你的布局虽然复杂,但是框架的滑动并不会引起布你复杂布局内部的调整。这个得看你的布局及activity逻辑怎么写。 目前也有直播/语音房间的app也用了这个库,如果方便的话,可以上传下你的Demo这个页面的代码,我定位下,上述的log无法直观反映问题。 @a154225859

不需要其他的代码 可以直接替换我这activity_douyin_live_layout.xml 到你的demo里测试 手机直播优于抖音效果的那个界面

YummyLau commented 3 years ago

@a154225859 你里面80个多个布局约束,一个layout重新计算,大量消耗了cpu资源。 系统做了 ChangeBound跟不上了,代码在框架内

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                val changeBounds = isBoundChange(l, contentContainerTop, r, panelContainerTop + compatPanelHeight)
                logFormatter.addContent("changeBounds", "$changeBounds")
                if (changeBounds) {
                    val reverseResetState = reverseResetState()
                    logFormatter.addContent("reverseResetState", "$reverseResetState")
                    if (reverseResetState) {
                        setTransition(animationSpeed.toLong(), panelId)
                    }
                } else {
                    //如果功能面板的互相切换,则需要判断是否存在高度不一致,如果不一致则需要过渡
                    if (lastPanelHeight != -1 && lastPanelHeight != compatPanelHeight) {
                        setTransition(animationSpeed.toLong(), panelId)
                    }
                }
            }

类型的布局完成可以用Recyclerview来实现,你里面约束很多都前后约束限制及容器自适应高度,这很容易引起性能问题。

YummyLau commented 3 years ago

如无进一步反馈,issue关闭,有问题随时打开追加信息。