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

无法复现Edge.computeEdge可能发生的NPE #372

Closed
LeonShannon opened this issue Jun 25, 2023 · 16 comments
Closed

无法复现Edge.computeEdge可能发生的NPE #372

LeonShannon opened this issue Jun 25, 2023 · 16 comments
Labels
寻求帮助 Extra attention is needed

Comments

@LeonShannon
Copy link

问题描述

用了StaggeredGridLayoutManager的地方就是这里。但是没有复现出来

image image

期望行为

如何复现

任何业务相关问题没有fork仓库复现问题一律无法解决, 凭空猜测只会让问题晦涩难懂, 大量耽误项目维护时间

截图

image

异常堆栈信息或者手机截图/视频(拖拽到输入框即可上传)

版本

  • BRV:1.4.1
  • Android:任何版本都存在
  • Gradle: 8.1.1
  • Android Studio:Android Studio Hedgehog | 2023.1.1 Canary 9
@LeonShannon LeonShannon added the 寻求帮助 Extra attention is needed label Jun 25, 2023
@liangjingkanji
Copy link
Owner

staggered()这个函数本身就是设置layoutManager, 但是我看你又再layoutManager设置一遍, 我不太能理解你写的代码含义

查看异常本身我认为发生在com/drake/brv/DefaultDecoration.kt:727

when (layoutManager) {
    is StaggeredGridLayoutManager -> {
        val spanCount = layoutManager.spanCount
        val spanIndex = (layoutManager.findViewByPosition(position)?.layoutParams
                as StaggeredGridLayoutManager.LayoutParams).spanIndex + 1

我认为这个异常和你自己定义的LayoutManager可能存在一定关系

@LeonShannon
Copy link
Author

设置了两次layoutManager,是我在测试代码。线上环境就只有staggered(2)

@liangjingkanji
Copy link
Owner

你提供不了fork仓库复现的代码, 所以我只能猜测, 上面就是我的猜测

@LeonShannon
Copy link
Author

我是在list 上面有个header,有没有可能 header 数据为空了然后导致的 NPE,本地无法复现不确定。
我发现有个方法可以指定布局类型添加 itemDecoration
image
我先把这个这方法加上,然后再做一下空数据,不添加 header 的处理,线上跑跑看看还有问题没

@liangjingkanji
Copy link
Owner

liangjingkanji commented Jul 9, 2023

我认为问题发生在

layoutManager.findViewByPosition(position) 返回null导致的NPE

已经发布新版本1.4.2修复此问题

@liangjingkanji liangjingkanji changed the title 一个无法复现的问题 无法复现Edge.computeEdge可能发生的NPE Jul 9, 2023
@liangjingkanji
Copy link
Owner

试了下如果没问题给个反馈吧

@LeonShannon
Copy link
Author

LeonShannon commented Jul 20, 2023

抱歉之前休假没有及时回复。
QA 找到了问题,不是所有机型都可以复现,目前发现是三星 S21 和华为部分机型稳定复现

业务点是添加一条新的数据到list 中,在添加之前有header 和瀑布流。(111 就是添加的那条内容)
image

使用addModels是会产生崩溃问题,使用蓝框中方法,可以正常实现业务
image

@LeonShannon
Copy link
Author

我使用该方式,在 bugly 上面看,只是减少了部分 crash,不确定我说的addModels是不是全部case了。需要这个版本上线之后继续观察

@liangjingkanji
Copy link
Owner

我发布的新版本1.4.2上线了只是减少了部分crash? 依旧存在这个问题是吗?

.... 我先把这个这方法加上,然后再做一下空数据,不添加 header 的处理,线上跑跑看看还有问题没

还是说你之前提到的那种解决方式?

@liangjingkanji
Copy link
Owner

以下为我修复代码, 该函数存在可能为null情况
image

@liangjingkanji
Copy link
Owner

不过你这个截图看着倒是挺眼熟, 这不是BRV的sample-首页布局抄的app界面吗

@LeonShannon
Copy link
Author

不是,减少的 crash 是我做了一些 header 数据的空判断。
截图是我们线上 App=。=
具体问题还没有追到,等我发了版我仔细研究下

@liangjingkanji
Copy link
Owner

liangjingkanji commented Jul 22, 2023

我也是PS5玩家有用你们App(感觉你们算目前同类型最好的产品了, 二柄app太粗制滥造的感觉)
这个开源项目的"首页"示例就是抄的你们产品, 是我抄的太潦草吗? 你都没看出来
欢迎你们参与这个项目让brv/sample更完善, 开源用户即作者

@LeonShannon
Copy link
Author

我那天跑 demo 的时候,我看到你的首页样式还恍惚了呢。我说和我们咋那么像,hhhhhh,太巧了

@liangjingkanji
Copy link
Owner

liangjingkanji commented Jul 24, 2023

因为感觉你们app做的很好很适合演示, 我写的也没你们好, 有空欢迎你优化下

如果线上新版本还存在该问题会继续跟踪问题

@liangjingkanji
Copy link
Owner

问题有解决吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
寻求帮助 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants