From 366a441cf2b7ce64f68104d2af4bcf2e9c321bbd Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 14:14:04 +0800 Subject: [PATCH 1/3] fix --- server/websocket/internal/logic/ws_render_image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 5aca8d95..2850af1a 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -202,6 +202,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe logx.Error("failed to find render resource:", err) return } + logx.Info("无缓存的渲染图,需要unity") } else { //返回给客户端 w.sendRenderResultData(websocket_data.RenderImageRspMsg{ From e4c165cd181e9139f6530e7043215c3705e7383d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 14:29:21 +0800 Subject: [PATCH 2/3] fix --- server/websocket/internal/logic/ws_render_image.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 2850af1a..faf35cf6 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -23,7 +23,7 @@ var ( //每个websocket渲染任务缓冲队列长度默认值 renderChanLen = 500 //每个websocket渲染并发数 - renderChanConcurrency = 15 + renderChanConcurrency = 3 ) // 渲染处理器 @@ -33,6 +33,8 @@ type renderProcessor struct { // 云渲染属性 type extendRenderProperty struct { renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列 + selectColorIndex int //颜色选中索引 + templateTag string //模板标签 } // 处理分发到这里的数据 @@ -48,6 +50,8 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { case <-w.closeChan: //已经关闭 return case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列 + w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag + w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex return } } @@ -67,6 +71,14 @@ func (w *wsConnectItem) consumeRenderImageData() { case <-w.closeChan: //已关闭 return case data := <-w.extendRenderProperty.renderChan: //消费数据 + if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag{ + logx.Error("由于模板切换了,丢弃该渲染消息") + continue + } + if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex{ + logx.Error("由于模板切换了颜色,丢弃该渲染消息") + continue + } limitChan <- struct{}{} go func(d websocket_data.RenderImageReqMsg) { defer func() { From 20150a81b59389ec779f8fa2c0593dcacecb5235 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 14:33:16 +0800 Subject: [PATCH 3/3] fix --- server/websocket/internal/logic/ws_render_image.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index faf35cf6..e488c8d1 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -72,11 +72,11 @@ func (w *wsConnectItem) consumeRenderImageData() { return case data := <-w.extendRenderProperty.renderChan: //消费数据 if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag{ - logx.Error("由于模板切换了,丢弃该渲染消息") + logx.Info("由于模板切换了,丢弃该渲染消息") continue } if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex{ - logx.Error("由于模板切换了颜色,丢弃该渲染消息") + logx.Info("由于模板切换了颜色,丢弃该渲染消息") continue } limitChan <- struct{}{}