Skip to content

NoSuchMethodError: 'callMethodVarArgs' when calling getStats() #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
renefloor opened this issue Mar 11, 2025 · 5 comments · Fixed by #61
Closed

NoSuchMethodError: 'callMethodVarArgs' when calling getStats() #60

renefloor opened this issue Mar 11, 2025 · 5 comments · Fixed by #61

Comments

@renefloor
Copy link
Contributor

Related issue: flutter-webrtc/flutter-webrtc#1781

In this release stats.callMethodVarArgs('forEach'.toJS, [ ... ]); was introduced:
439c8ef#diff-5523a536631aaa1af43c73105f4e719d85cac17e5e6d13f2b1f0bd69d533aabdL324-R339

Running this now on web gives the following error:

NoSuchMethodError: 'callMethodVarArgs'
method not found
Receiver: Instance of 'RtcStatsReport'
Arguments: ["forEach", Instance of 'JSArray<Object?>']

When reverting lines 326-339 to the old ones everything runs fine. What is the reason this change was made in the first place? Is the old code broken with wasm?

@EvertonMJunior
Copy link

+1 on this

@renefloor
Copy link
Contributor Author

@EvertonMJunior I see that you made this change: StiftTechnologies@8431d6c

That change makes sense, because otherwise the variable type is not known. Is that enough to fix the issue? Maybe you could make a PR to this repo to suggest the change?

@EvertonMJunior
Copy link

EvertonMJunior commented Mar 13, 2025

@renefloor yes, the change did remove the error presented above, I didn't make a PR yet because everything worked on debug mode, but I ran into other issues I didn't have the time to debug yet on Web release mode, so I'm not 100% sure if the problem was actually solved, if it's solved only in debug for some reason, or if it was solved and there are other issues that hadn't appeared yet due to not being able to proceed because of this issue. I preferred to keep using the 1.4.10 version for now as I don't have the time to pin it down and solve it myself now. But feel free to try it too!

@renefloor
Copy link
Contributor Author

@EvertonMJunior for me it also fixed it for debug mode, but not for release mode. The error did change though, I got:
Failed to execute 'forEach' on 'RTCStatsReport': parameter 1 is not of type 'Function'.

This makes me look closer to the function. On line 338 it's calling .jsify() to convert the dart function to a JS function. However, the docs of jsify say

Only Dart primitives, [Iterable]s, typed lists, and [Map]s are supported.

So I suspect that jsify turns it into something that's not a function.

The original logs also said:

Arguments: ["forEach", Instance of 'JSArray<Object?>']

So I guess that JSArray<Object?> does not contain a Function either.

@renefloor
Copy link
Contributor Author

renefloor commented Mar 19, 2025

@EvertonMJunior I got it working by combining your fix with a change on line 338.
Change }.jsify() into }.toJS. As said in my previous comment, jsify only works on primitives. toJS converts it to a JSExportedDartFunction.

Edit: opened a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants