function loadImage(imageURL, scale9grid) {
// console.warn("loadImage",imageURL)
return new Promise((resolve, reject) => {
const image = wx.createImage();
var startLoadTime = Date.now()
image.onload = () => {
let passTime = Date.now() - startLoadTime
if (passTime > 1000) {
console.warn("耗时:", passTime, imageURL)
}
const bitmapdata = new egret.BitmapData(image);
const texture = new egret.Texture();
texture._setBitmapData(bitmapdata);
if (scale9grid) {
texture["scale9Grid"] = scale9grid;
}
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
if (systemInfo.platform == "ios") {
setTimeout(() => {
resolve(texture);
}, 0);
} else {
resolve(texture);
}
}
image.onerror = (e) => {
// console.error(e);
const error = new RES.ResourceManagerError(1001, imageURL);
reject(error);
}
image.src = imageURL;
})
}
通过这种方式去远程加载图片,Android手机上集中在1800ms-5000ms,开发者工具上出现在1200ms-1500ms,表现就是模型加载异常缓慢,老板已经催炸天了,求搭救哇