cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.31k stars 1.95k forks source link

Browser type errors #17815

Open longchuan opened 5 hours ago

longchuan commented 5 hours ago

Cocos Creator version

3.8.4

System information

windows 11

Issue description

image image The useragent of windows edge.And there were many errors in mobile too.

Relevant error log output

No response

Steps to reproduce

console.log(sys.browserType);
console.log(sys.browserVersion);
console.log(navigator.userAgent);

Minimal reproduction project

No response

longchuan commented 5 hours ago

Perhaps,slice the useragent to 1/2,and exec the "edg" will be more faster. Maybe,the old edge's useragent was "edge" Perhaps,cocos engine can let developers to select the supported browser.

longchuan commented 5 hours ago

And,cancel the method of "toLowerCase" will be more faster.The useragent will not be change in many times.

longchuan commented 5 hours ago

Perhaps,slice the useragent to 1/2,and exec the "edg" will be more faster.

such as:

if(useragent.length>12){
     useragent = useragent.slice(useragent.length/2,useragent.length);
}

calculate the time of "if" and the time of slice,this will solve many problems about what causes project a slow one. and put the more time used part to init. For the end,let developers to load them in init. Cocos' init was not necessary.