Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 10 以及Android 10 以下,出现下面的崩溃,看日志 #216

Open
lianyagang opened this issue Oct 28, 2024 · 11 comments
Open

Comments

@lianyagang
Copy link

  1. 现象:崩溃
  2. 场景:线上的场景,不知道用户怎么操作的
  3. 系统版本:目前是大量Android10 以及以下的出现崩溃,Android10以上是没有出现过
  4. 疑问:com.effective.android.panel.view.content.ContentContainerImpl.layoutContainer(ContentContainerImpl.kt:380) 这个摆放的时候,如果在低端机,或者低内存下,渲染不及时,不是会有问题吗?

Fatal Exception: java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true com.xxxx.AutoHideXXxxPanelRecyclerView{cf58a2a VFED..... ......ID 0,0-720,1001 #7f0a0c38 app:id/recyclerView}, adapter:com.xxx.adapter.wrapper.HeaderAndFooterAdapterWrapper@65191a4, layout:com.xxxx..CatchLinearLayoutManager@1ff57, context:com.XXXX.ChatActivity@d5425a5
at androidx.recyclerview.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:7071)
at androidx.recyclerview.widget.RecyclerView$Recycler.quickRecycleScrapView(RecyclerView.java:7194)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeAndRecycleScrapInt(RecyclerView.java:10076)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4717)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4367)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4919)
at android.view.View.layout(View.java:20956)
at android.view.ViewGroup.layout(ViewGroup.java:6396)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
at android.view.View.layout(View.java:20956)
at android.view.ViewGroup.layout(ViewGroup.java:6396)
at com.effective.android.panel.view.content.ContentContainerImpl.layoutContainer(ContentContainerImpl.kt:380)

@15359947959

This comment was marked as off-topic.

@lianyagang
Copy link
Author

收到了,辛苦啦

补充一下。我使用的版本是1.5.0

@HeroZ-Dodge
Copy link
Collaborator

这个异常,看上去像是由于业务逻辑引起的~

@lianyagang
Copy link
Author

这个异常,看上去像是由于业务逻辑引起的~

不太好确定边界行。因为Android10 以上,确实一个崩溃都没有。如果是业务的问题。应该是机型覆盖比较广的。而且,我们大量都是Android11+的用户

@lianyagang
Copy link
Author

这个异常,看上去像是由于业务逻辑引起的~

或者说,我可以采用什么方式来捕获这个异常。起码不要崩溃呢?

@HeroZ-Dodge
Copy link
Collaborator

你可以尝试从你们定义的 CatchLinearLayoutManager 入手试试

@lianyagang
Copy link
Author

你可以尝试从你们定义的 CatchLinearLayoutManager 入手试试

这个类,没啥代码呀。只有 try catch。没了。
class CatchLinearLayoutManager @jvmoverloads constructor(
context: Context?,
orientation: Int = RecyclerView.VERTICAL,
reverseLayout: Boolean = false
) : LinearLayoutManager(context, orientation, reverseLayout) {

override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) {
    kotlin.runCatching {
        super.onLayoutChildren(recycler, state)
    }
}

}

@lianyagang
Copy link
Author

这个异常,看上去像是由于业务逻辑引起的~

你不是作者啊。。。。给我干蒙圈了。。。。不要瞎回复啊。。。。

@lianyagang
Copy link
Author

internal fun bindWindow(window: Window, windowInsetsRootView: View?) { this.window = window this.windowInsetsRootView = windowInsetsRootView keyboardAnimation = enableKeyboardAnimator && supportKeyboardAnimation() if (keyboardAnimation) { // 通过监听键盘动画,修改translationY线上面板 keyboardChangedAnimation() } else { // 通过获取键盘高度,触发onLayout修改面板高度 deviceRuntime = DeviceRuntime(context, window) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) deviceRuntime?.let { contentContainer.getInputActionImpl().updateFullScreenParams(it.isFullScreen, panelId, getCompatPanelHeight(panelId)) if (supportKeyboardFeature()) { keyboardChangedListener30Impl() } else { keyboardChangedListener(window, it) } hasAttachLister = true } } }
源码这里, // 通过获取键盘高度,触发onLayout修改面板高度 这里的兼容是有问题的。Android10 以下,这个高度的获取等,都可能导致onLayout触发到RecycleView的刷新,以及回收。这里应该再处理下兜底策略
@15359947959

@YummyLau
Copy link
Collaborator

这个异常,看上去像是由于业务逻辑引起的~

你不是作者啊。。。。给我干蒙圈了。。。。不要瞎回复啊。。。。

@HeroZ-Dodge 是官方的

@YummyLau
Copy link
Collaborator

internal fun bindWindow(window: Window, windowInsetsRootView: View?) { this.window = window this.windowInsetsRootView = windowInsetsRootView keyboardAnimation = enableKeyboardAnimator && supportKeyboardAnimation() if (keyboardAnimation) { // 通过监听键盘动画,修改translationY线上面板 keyboardChangedAnimation() } else { // 通过获取键盘高度,触发onLayout修改面板高度 deviceRuntime = DeviceRuntime(context, window) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) deviceRuntime?.let { contentContainer.getInputActionImpl().updateFullScreenParams(it.isFullScreen, panelId, getCompatPanelHeight(panelId)) if (supportKeyboardFeature()) { keyboardChangedListener30Impl() } else { keyboardChangedListener(window, it) } hasAttachLister = true } } } 源码这里, // 通过获取键盘高度,触发onLayout修改面板高度 这里的兼容是有问题的。Android10 以下,这个高度的获取等,都可能导致onLayout触发到RecycleView的刷新,以及回收。这里应该再处理下兜底策略 @15359947959

我们测试下,感谢反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants