Javascript 源于视频currentTime的searchElement的原子索引bug

Javascript 源于视频currentTime的searchElement的原子索引bug,javascript,arrays,google-chrome,indexof,Javascript,Arrays,Google Chrome,Indexof,我对mac上当前版本Chrome37.0.2062.94中数组indexOf的不可预测结果感到困惑。有时使用视频元素的时间码创建searchElement时,array.indexOf似乎不起作用 要查看错误,请让视频播放几秒钟,然后在array.indexOf错误发生时停止播放。这似乎是原子操作中的一个bug?有什么东西是我忽略的吗 这是一个垃圾桶 var-trippedBugTimes=0; 函数tick(){ var nowTime=document.getElementById('vi

我对mac上当前版本Chrome37.0.2062.94中数组indexOf的不可预测结果感到困惑。有时使用视频元素的时间码创建searchElement时,array.indexOf似乎不起作用

要查看错误,请让视频播放几秒钟,然后在array.indexOf错误发生时停止播放。这似乎是原子操作中的一个bug?有什么东西是我忽略的吗

这是一个垃圾桶


var-trippedBugTimes=0;
函数tick(){
var nowTime=document.getElementById('video').currentTime;
//这似乎是至关重要的…如果val被分配到100,我们就不会得到错误。
var val=(nowTime-nowTime)+100;
//这似乎也很重要。我们不能将val作为数组的唯一成员,它必须是另一个变量。
var a=[100];
var idx=a.indexOf(val);
如果(idx==-1){
console.log(“*bug*”,
“idx->”,idx,
“val->”,val,
“a->”,a,
“a[0]==val->”,a[0]==val,
“类型a[0]->”,类型a[0],
“val类型->”,val类型);
document.getElementById('video').pause();
跳闸次数+=1;
}
如果(跳闸次数<100){
requestAnimationFrame(勾号);
}
否则{
日志(“错误报告完成”);
}
}
requestAnimationFrame(勾号);
setTimeout(document.getElementById('video').play(),1000);

如原帖子下的评论所述,该错误已报告给chromium团队。它已经被修复了(尽管没有已知的简单方法来确定bug是否在blink实现中…)


我已经向chrome团队发布了一份bug报告:
(nowTime-nowTime)+100背后的想法是什么而不是只写
100
?我不知道你为什么要从当前时间中减去当前时间?如果这是0呢?目的是什么?好的,我想
var val=nowTime-nowTime+100
总是100,但有时.indexOf会失败,现在我明白了。这很有趣。但是,为什么您需要执行
nowtime-nowtime
?这里的实际计算是什么?
<!DOCTYPE html>
<html>
<video id="video">
    <source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4">
</video>

<script>

var trippedBugTimes = 0;

function tick() {
    var nowTime = document.getElementById('video').currentTime;

    //this seems to be crucial... if val is just assigned 100, we don't get the bug.
    var val = (nowTime - nowTime) + 100;

    //this also seems to be important.. we cannot put val in as the sole member of the array, it has to be a different variable.
    var a = [100];
    var idx = a.indexOf( val );
    if (idx == -1) {
        console.log( "*bug*", 
            "idx ->", idx, 
            "val -> ", val, 
            "a ->", a, 
            "a[0] === val ->", a[0] === val, 
            "typeof a[0] ->", typeof a[0], 
            "typeof val ->", typeof val );

        document.getElementById('video').pause();

        trippedBugTimes += 1;
    }

    if (trippedBugTimes < 100) {
        requestAnimationFrame(tick);
    }
    else {
        console.log( "Bug reporting complete" );
    }
}
requestAnimationFrame(tick);

setTimeout( document.getElementById('video').play(), 1000 );
</script>
</html>