From fba280904e8dbb7fdcce0fd08700b02c885aa034 Mon Sep 17 00:00:00 2001 From: madixin Date: Wed, 27 Nov 2024 15:39:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E5=9B=BE=E5=92=8C=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=9B=BE=E5=B9=B6=E5=8F=91=E5=8A=A0=E8=BD=BD=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E4=B8=BB=E5=9B=BE=E5=8A=A0=E8=BD=BD=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=90=8E=E7=AB=8B=E5=8D=B3=E5=8A=A0=E8=BD=BD=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=9B=BE=EF=BC=8C=E5=8F=AF=E8=83=BD=E4=BC=9A=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9F=AD=E6=97=B6=E9=97=B4=E5=86=85=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E6=95=B0=E8=B6=85=E8=BF=87maxRequests=EF=BC=8C=E6=95=85?= =?UTF-8?q?=E5=9C=A8dispatchNextJob=E5=87=8F=E5=B0=91=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E5=B9=B6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: madixin --- library/src/main/ets/ImageKnifeDispatcher.ets | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/src/main/ets/ImageKnifeDispatcher.ets b/library/src/main/ets/ImageKnifeDispatcher.ets index 139b353..593e7e4 100644 --- a/library/src/main/ets/ImageKnifeDispatcher.ets +++ b/library/src/main/ets/ImageKnifeDispatcher.ets @@ -359,7 +359,7 @@ export class ImageKnifeDispatcher { let pixelmap = requestJobResult.pixelMap; if (pixelmap === undefined) { - LogUtil.error('ImageKnife_DataTime_getAndShowImage_CallBack.pixelmap undefined:'+currentRequest.imageKnifeOption.loadSrc + " error: " + requestJobResult.loadFail) + LogUtil.error('ImageKnife_DataTime_getAndShowImage_CallBack.pixelmap failed:'+currentRequest.imageKnifeOption.loadSrc + " error: " + requestJobResult.loadFail) requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => { requestWithSource.request.requestState = ImageKnifeRequestState.ERROR this.executingJobMap.remove(memoryKey); @@ -492,6 +492,12 @@ export class ImageKnifeDispatcher { dispatchNextJob() { LogUtil.log('ImageKnife_DataTime_dispatchNextJob.start') + + // 主图和错误图并发加载时,以及主图加载失败后立即加载错误图,可能会导致短时间内并发数超过maxRequests,故此处减少响应的并发 + if (this.executingJobMap.length >= this.maxRequests) { + return + } + while (true) { let request = this.jobQueue.pop() if (request === undefined) {