[]向官方反映1.75引擎库后 事件执行 发生的bug

在引擎1.75以后的laya.core.js库中,在2755行的执行事件处理中,获取到事件数组长度,之后执行相关逻辑,最后再把事件列表长度置0。这样出现的问题是,如果在执行事件中发生错误,下一帧的事件列表长度不为0,还是会进事件执行,可能会死循环。不知道写这段的时候是怎么考虑的,是不是取出时就应该及时的清空事件列表?
已邀请:

cuixueying

赞同来自:

你说的具体是哪个类,哪个方法,我们看下,谢谢!

fundge

赞同来自:

MouseManager中,
/**
        *执行事件处理。
        */
        __proto.runEvent=function(){
            var len=this._eventList.length;
            if (!len)return;
            var _this=this;
            var i=0;
            var localevnetList = this._eventList.slice();
            this._eventList.length = 0;
            while (i < len){
                var evt=localevnetList[i];
                if (evt.type!=='mousemove')this._prePoint.x=this._prePoint.y=-1000000;
                switch (evt.type){
                    case 'mousedown':
                        this._touchIDs[0]=this._id++;
                        if (!MouseManager._isTouchRespond){
                            _this._isLeftMouse=evt.button===0;
                            _this.initEvent(evt);
                            _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseDown);
                        }else
                        MouseManager._isTouchRespond=false;
                        break ;
                    case 'mouseup':
                        _this._isLeftMouse=evt.button===0;
                        _this.initEvent(evt);
                        _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseUp);
                        break ;
                    case 'mousemove':
                        if ((Math.abs(this._prePoint.x-evt.clientX)+Math.abs(this._prePoint.y-evt.clientY))>=this.mouseMoveAccuracy){
                            this._prePoint.x=evt.clientX;
                            this._prePoint.y=evt.clientY;
                            _this.initEvent(evt);
                            _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseMove);
                        }
                        break ;
                    case "touchstart":
                        MouseManager._isTouchRespond=true;
                        _this._isLeftMouse=true;
                        var touches=evt.changedTouches;
                        for (var j=0,n=touches.length;j < n;j++){
                            var touch=touches[j];
                            if (MouseManager.multiTouchEnabled || isNaN(this._curTouchID)){
                                this._curTouchID=touch.identifier;
                                if (this._id % 200===0)this._touchIDs={};
                                this._touchIDs[touch.identifier]=this._id++;
                                _this.initEvent(touch,evt);
                                _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseDown);
                            }
                        }
                        break ;
                    case "touchend":
                        MouseManager._isTouchRespond=true;
                        _this._isLeftMouse=true;
                        var touchends=evt.changedTouches;
                        for (j=0,n=touchends.length;j < n;j++){
                            touch=touchends[j];
                            if (MouseManager.multiTouchEnabled || touch.identifier==this._curTouchID){
                                this._curTouchID=NaN;
                                _this.initEvent(touch,evt);
                                _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseUp);
                            }
                        }
                        break ;
                    case "touchmove":;
                        var touchemoves=evt.changedTouches;
                        for (j=0,n=touchemoves.length;j < n;j++){
                            touch=touchemoves[j];
                            if (MouseManager.multiTouchEnabled || touch.identifier==this._curTouchID){
                                _this.initEvent(touch,evt);
                                _this.check(_this._stage,_this.mouseX,_this.mouseY,_this.onMouseMove);
                            }
                        }
                        break ;
                    case "wheel":
                    case "mousewheel":
                    case "DOMMouseScroll":
                        _this.checkMouseWheel(evt);
                        break ;
                    case "mouseout":
                        _this._stage.event(/*laya.events.Event.MOUSE_OUT*/"mouseout",_this._event.setTo(/*laya.events.Event.MOUSE_OUT*/"mouseout",_this._stage,_this._stage));
                        break ;
                    case "mouseover":
                        _this._stage.event(/*laya.events.Event.MOUSE_OVER*/"mouseover",_this._event.setTo(/*laya.events.Event.MOUSE_OVER*/"mouseover",_this._stage,_this._stage));
                        break ;
                    }
                i++;
            }
            this._eventList.length=0;
        }

fundge

赞同来自:

事情是这样的,在loop循环中,我们遇到错误,抛出了一个异常,那这个时候loop就是不执行了。我们的处理方法是在抛出异常后,再一次调用loop执行下一帧,那这个时候,这个事件里面的方法就会出现问题。如果考虑错误抛出而继续执行loop,请教官方有什么处理方法吗??

要回复问题请先

商务合作
商务合作