From 971688cf495a363ac86ee80d1ed33f4a2e9582cb Mon Sep 17 00:00:00 2001 From: drawcall Date: Sat, 3 Feb 2024 16:36:37 +0800 Subject: [PATCH] feat: Add detailed log feat: Add detailed log --- lib/center/center.js | 10 ++++++++++ lib/core/renderer.js | 15 +++++++++------ lib/creator.js | 3 +++ package.json | 2 +- types/lib/FFCreator.d.ts | 2 ++ types/lib/FFEventer.d.ts | 2 +- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/center/center.js b/lib/center/center.js index eb439c42..2b78e0fe 100755 --- a/lib/center/center.js +++ b/lib/center/center.js @@ -32,6 +32,7 @@ const FFCreatorCenter = { num: 0, delay: 500, state: 'free', + log: false, temps: {}, progress: new Progress(), event: new EventEmitter(), @@ -53,6 +54,10 @@ const FFCreatorCenter = { FFLogger.enable = true; }, + openCatchLog() { + this.log = true; + }, + /** * Add a production task * @param {function} task - a production task @@ -175,11 +180,16 @@ const FFCreatorCenter = { this.initCreator(creator, taskObj); } } catch (error) { + if (this.log) console.log(error); this.handlingError({ taskObj, error }); } }, initCreator(creator, taskObj) { + if (creator.destroyed) { + return setTimeout(this.nextTask.bind(this), this.delay); + } + creator.inCenter = true; creator.generateOutput(); diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 51617fb3..cc100ac7 100755 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -297,12 +297,15 @@ class Renderer extends FFBase { destroy() { // GLReset(this.gl)(); - this.stream.destroy(); - this.timeline.destroy(); - this.synthesis.destroy(); - this.removeCacheFiles(); - this.removeAllListeners(); - super.destroy(); + try{ + this.stream.destroy(); + this.timeline.destroy(); + this.synthesis.destroy(); + this.removeCacheFiles(); + this.removeAllListeners(); + super.destroy(); + }catch(e) { + } this.stop = true; this.gl = null; diff --git a/lib/creator.js b/lib/creator.js index 70d6cd15..1dcfd15c 100755 --- a/lib/creator.js +++ b/lib/creator.js @@ -38,6 +38,7 @@ class FFCreator extends FFCon { this.inCenter = false; this.conf = new Conf(conf); this.loader = new Loader(); + this.destroyed = false; this.createApp(); this.createRenderer(); @@ -275,6 +276,7 @@ class FFCreator extends FFCon { async start(delay = 25) { await Utils.sleep(delay); await this.checkDurationOfLegalTransitions(); + if (this.destroyed) return; this.addRenderEvent(); this.renderer.start(); } @@ -408,6 +410,7 @@ class FFCreator extends FFCon { this.destroyApp(); super.destroy(); + this.destroyed = true; this.conf = null; this.loader = null; this.display = null; diff --git a/package.json b/package.json index a55b1c19..e448da73 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ffcreator", - "version": "7.2.2", + "version": "7.3.1", "description": "FFCreator is a lightweight and flexible short video production library", "main": "lib/index.js", "types": "types/index.d.ts", diff --git a/types/lib/FFCreator.d.ts b/types/lib/FFCreator.d.ts index d21cbc7f..a2d04324 100644 --- a/types/lib/FFCreator.d.ts +++ b/types/lib/FFCreator.d.ts @@ -155,6 +155,8 @@ declare namespace FFCreatorSpace { */ setCover(cover: string): void; + destroy():void; + /** * Create new effect and add to effects object * @param name the new effect name diff --git a/types/lib/FFEventer.d.ts b/types/lib/FFEventer.d.ts index d1436058..4ba0ceee 100644 --- a/types/lib/FFEventer.d.ts +++ b/types/lib/FFEventer.d.ts @@ -61,6 +61,6 @@ declare namespace FFCreatorSpace { */ bubble(eventer: unknown): void; - destory(): void; + destroy(): void; } }