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 日期选择会崩溃 #83

Open
lyyqqrr opened this issue Oct 26, 2016 · 17 comments
Open

升级到新版本 Android 日期选择会崩溃 #83

lyyqqrr opened this issue Oct 26, 2016 · 17 comments

Comments

@lyyqqrr
Copy link

lyyqqrr commented Oct 26, 2016

项目中一直利用react-native-picker实现日期组件,然而从JS升到原生版本后,
Android在调试模式下直接崩溃,release版偶尔也会出现,RN版本0.35。
是否跟pickerData的数据量有关?

@shexiaoheng
Copy link
Contributor

你是怎么升级的?说下详细的升级步骤,看看是不是什么地方遗漏了

@lyyqqrr
Copy link
Author

lyyqqrr commented Oct 26, 2016

是这样的,之前使用的3.0.5 现在升到4.0.8版本,然后按照demo重新实现了日期组件。ios下调试正常,android下就出现崩溃现象,其他利用react-native-picker实现的选项不存在这种问题。

@shexiaoheng
Copy link
Contributor

错误日志贴一下

@xwenliang
Copy link
Member

使用最新的[email protected]确实有崩溃的问题,但是使用示例代码[email protected]就没有这个问题,我们会尝试解决它 @shexiaoheng

@shexiaoheng
Copy link
Contributor

当年份为20352050时没有问题,当年份小于2035时(比如2034)程序就会退出,然而并没有错误日志,应该是RN版本升级做了限制或者误改了代码导致,等RNv0.37发布了看看会不会修复吧。

下列代码可以正常运行

function createDateData(){
    let date = [];
    for(let i=2035;i<2050;i++){
        let month = [];
        for(let j = 1;j<13;j++){
            let day = [];
            if(j === 2){
                for(let k=1;k<29;k++){
                    day.push(k+'日');
                }
            }
            else if(j in {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1}){
                for(let k=1;k<32;k++){
                    day.push(k+'日');
                }
            }
            else{
                for(let k=1;k<31;k++){
                    day.push(k+'日');
                }
            }
            let _month = {};
            _month[j+'月'] = day;
            month.push(_month);
        }
        let _date = {};
        _date[i+'年'] = month;
        date.push(_date);
    }
    return date;
};

下列代码会闪退

function createDateData(){
    let date = [];
    for(let i=2034;i<2050;i++){
        let month = [];
        for(let j = 1;j<13;j++){
            let day = [];
            if(j === 2){
                for(let k=1;k<29;k++){
                    day.push(k+'日');
                }
            }
            else if(j in {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1}){
                for(let k=1;k<32;k++){
                    day.push(k+'日');
                }
            }
            else{
                for(let k=1;k<31;k++){
                    day.push(k+'日');
                }
            }
            let _month = {};
            _month[j+'月'] = day;
            month.push(_month);
        }
        let _date = {};
        _date[i+'年'] = month;
        date.push(_date);
    }
    return date;
};

@lyyqqrr
Copy link
Author

lyyqqrr commented Oct 28, 2016

确实如此,RN 0.36这个问题仍存在,看来只能等更新了

@277850318
Copy link

我的rn0.36 android跑example选日期一样崩溃

@xwenliang
Copy link
Member

嗯,我们已经去官方提issue了但是还没有回复:facebook/react-native#10590 (comment)

我们也尝试了放弃ReadableMap改用String传参,然后安卓端自己解析字符串,这种方式虽然不会崩溃了但会导致执行效率降低很多,从点击到出现日期picker大概有1.5s的延迟,还是等官方解决这个问题吧

@susan-github
Copy link

闪退问题有结论了么,我RN0.38.0的,魅族上2005-2020都直接崩溃了,是性能问题么?

@xwenliang
Copy link
Member

@ALL
问题有了初步结论:debug包确实会崩溃,打成离线包就不会崩了,猜想原因可能是debug会做很多的监听导致很多额外的性能开销导致。

@iamdurui
Copy link

iamdurui commented Jan 8, 2017

我的0.38安卓也是崩溃,在三星note3上,还有华为p8上也是一样的

@shexiaoheng
Copy link
Contributor

@iamdurui 离线包也会崩溃?

@JusticeLai
Copy link

晕..为啥2035年后就不会崩溃...0.40的RN版本

@shexiaoheng
Copy link
Contributor

@JusticeLai 打成离线包你可以从1905开始都不会崩溃

@JusticeLai
Copy link

image
打包后,找不到资料哪里修改,运行不了离线包...@shexiaoheng

@iamdurui
Copy link

iamdurui commented Feb 9, 2017

@shexiaoheng 哥,那这个怎么办啊?我主要开发安卓,安卓上的debug模式老是崩溃,没法弄了啊,

@shexiaoheng
Copy link
Contributor

@iamdurui 减少数据量,看上面我发的第三条评论,你可以只写2015年到2020年的,应该不影响你调试

rodolphefauquez pushed a commit to Clintal/react-native-picker that referenced this issue Feb 16, 2018
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

7 participants