Browse Source

[3.x] Fix JavaScript callback memory leak

SysError99 2 years ago
parent
commit
8ac91f813f
1 changed files with 3 additions and 1 deletions
  1. 3 1
      platform/javascript/js/libs/library_godot_javascript_singleton.js

+ 3 - 1
platform/javascript/js/libs/library_godot_javascript_singleton.js

@@ -205,7 +205,9 @@ const GodotJSWrapper = {
 				return;
 			}
 			const args = Array.from(arguments);
-			func(p_ref, GodotJSWrapper.get_proxied(args), args.length);
+			const argsProxy = new GodotJSWrapper.MyProxy(args);
+			func(p_ref, argsProxy.get_id(), args.length);
+			argsProxy.unref();
 		};
 		id = GodotJSWrapper.get_proxied(cb);
 		return id;