Feature/zpf (#564)

* iOS: fix memory leak of blur effect

* js: fix callback cause memory leak
This commit is contained in:
osborn
2022-12-20 15:06:46 +08:00
committed by GitHub
parent c60754c53d
commit be4fb05f91
13 changed files with 77 additions and 22 deletions

View File

@@ -17203,6 +17203,7 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
context.callbacks.delete(callbackId);
}
function jsCallReject(contextId, callbackId, args) {
var arguments$1 = arguments;
@@ -17223,6 +17224,7 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
context.callbacks.delete(callbackId);
}
var Context = /** @class */ (function () {
function Context(id) {

View File

@@ -1247,6 +1247,9 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId);
}
}
function jsCallReject(contextId, callbackId, args) {
const context = gContexts.get(contextId);
@@ -1265,6 +1268,9 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId);
}
}
class Context {
constructor(id) {
@@ -1328,7 +1334,8 @@ var doric = (function (exports) {
const functionId = uniqueId('function');
this.callbacks.set(functionId, {
resolve: func,
reject: () => { loge("This should not be called"); }
reject: () => { loge("This should not be called"); },
retained: true,
});
return functionId;
}

View File

@@ -1258,6 +1258,9 @@ function jsCallResolve(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId);
}
}
function jsCallReject(contextId, callbackId, args) {
const context = gContexts.get(contextId);
@@ -1276,6 +1279,9 @@ function jsCallReject(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId);
}
}
class Context {
constructor(id) {
@@ -1339,7 +1345,8 @@ class Context {
const functionId = uniqueId('function');
this.callbacks.set(functionId, {
resolve: func,
reject: () => { loge("This should not be called"); }
reject: () => { loge("This should not be called"); },
retained: true,
});
return functionId;
}

View File

@@ -7,6 +7,7 @@ export declare class Context {
callbacks: Map<string, {
resolve: Function;
reject: Function;
retained?: boolean;
}>;
classes: Map<string, ClassType<object>>;
hookBeforeNativeCall(): void;

View File

@@ -45,6 +45,9 @@ export function jsCallResolve(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId);
}
}
export function jsCallReject(contextId, callbackId, args) {
const context = gContexts.get(contextId);
@@ -63,6 +66,9 @@ export function jsCallReject(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId);
}
}
export class Context {
constructor(id) {
@@ -126,7 +132,8 @@ export class Context {
const functionId = uniqueId('function');
this.callbacks.set(functionId, {
resolve: func,
reject: () => { loge("This should not be called"); }
reject: () => { loge("This should not be called"); },
retained: true,
});
return functionId;
}

View File

@@ -84,6 +84,9 @@ export function jsCallResolve(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.resolve, context, argumentsList)
if (callback.retained !== true) {
context.callbacks.delete(callbackId)
}
}
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
@@ -103,12 +106,15 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.reject, context.entity, argumentsList)
if (callback.retained !== true) {
context.callbacks.delete(callbackId)
}
}
export class Context {
entity: any
id: string
callbacks: Map<string, { resolve: Function, reject: Function }> = new Map
callbacks: Map<string, { resolve: Function, reject: Function, retained?: boolean }> = new Map
classes: Map<string, ClassType<object>> = new Map
hookBeforeNativeCall() {
@@ -144,7 +150,8 @@ export class Context {
const functionId = uniqueId('function')
this.callbacks.set(functionId, {
resolve: func,
reject: () => { loge("This should not be called") }
reject: () => { loge("This should not be called") },
retained: true,
})
return functionId
}

View File

@@ -95,6 +95,9 @@ export function jsCallResolve(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.resolve, context, argumentsList)
if (callback.retained !== true) {
context.callbacks.delete(callbackId)
}
}
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
@@ -114,12 +117,15 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.reject, context.entity, argumentsList)
if (callback.retained !== true) {
context.callbacks.delete(callbackId)
}
}
export class Context {
entity: any
id: string
callbacks: Map<string, { resolve: Function, reject: Function }> = new Map
callbacks: Map<string, { resolve: Function, reject: Function, retained?: boolean }> = new Map
classes: Map<string, ClassType<object>> = new Map
hookBeforeNativeCall() {
@@ -182,7 +188,8 @@ export class Context {
const functionId = uniqueId('function')
this.callbacks.set(functionId, {
resolve: func,
reject: () => { loge("This should not be called") }
reject: () => { loge("This should not be called") },
retained: true,
})
return functionId
}