Skip to content

Commit

Permalink
fix: jira CSD-60920 render issue after (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 authored Nov 16, 2023
1 parent 8049ba9 commit 5730d86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
50 changes: 21 additions & 29 deletions ts/Renderer/RendererManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class RendererManager extends IRendererManager {
/**
* @ignore
*/
renderMode: RENDER_MODE;
renderMode?: RENDER_MODE;
/**
* @ignore
*/
Expand All @@ -62,9 +62,7 @@ export class RendererManager extends IRendererManager {
super();
this.renderFps = 15;
this.renderers = new Map();
this.renderMode = this.checkWebglEnv()
? RENDER_MODE.WEBGL
: RENDER_MODE.SOFTWARE;
this.setRenderMode();
this.msgBridge = AgoraEnv.AgoraElectronBridge;
this.defaultRenderConfig = {
rendererOptions: {
Expand All @@ -83,11 +81,20 @@ export class RendererManager extends IRendererManager {
* @returns
* 0: Success.< 0: Failure.
*/
public setRenderMode(mode: RENDER_MODE) {
this.renderMode = mode;
logInfo(
'setRenderMode: new render mode will take effect only if new view bind to render'
);
public setRenderMode(mode?: RENDER_MODE) {
if (mode === undefined) {
this.renderMode = this.checkWebglEnv()
? RENDER_MODE.WEBGL
: RENDER_MODE.SOFTWARE;
return;
}

if (mode !== this.renderMode) {
this.renderMode = mode;
logInfo(
'setRenderMode: new render mode will take effect only if new view bind to render'
);
}
}

/**
Expand Down Expand Up @@ -430,17 +437,6 @@ export class RendererManager extends IRendererManager {
}
}

/**
* @ignore
*/
private getRender({
videoSourceType,
channelId,
uid,
}: VideoFrameCacheConfig) {
return this.renderers.get(videoSourceType)?.get(channelId)?.get(uid);
}

/**
* @ignore
*/
Expand Down Expand Up @@ -475,18 +471,14 @@ export class RendererManager extends IRendererManager {
return filterRenders[0];
}
const renderer = this.createRenderer(() => {
const renderConfig = this.getRender(config);
if (!renderConfig) {
return;
}
renderConfig.renders = renders.filter((r) => r !== renderer);
const contentMode = renderer.contentMode;
const { contentMode, mirror } = renderer;
renderer.unbind();
this.setRenderMode(RENDER_MODE.SOFTWARE);
renders.splice(renders.indexOf(renderer), 1);
this.setRenderMode();
const newRender = this.createRenderer();
newRender.contentMode = contentMode;
newRender.bind(view);
renderConfig.renders.push(newRender);
newRender.setRenderOption({ contentMode, mirror });
renders.push(newRender);
});
renderer.bind(view);
renders.push(renderer);
Expand Down
3 changes: 2 additions & 1 deletion ts/Renderer/WebGLRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ export class GlRenderer extends IRenderer {
}
}

private handleContextLost = () => {
private handleContextLost = (event: Event) => {
console.warn('webglcontextlost', event);
try {
this.canvas &&
this.canvas.removeEventListener(
Expand Down

0 comments on commit 5730d86

Please sign in to comment.