GDNative overridden modules issue (WebRTC)
- Langage dominant
- C++
- Étoiles
- 1.1k
- Forks
- 80
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi,
This is a bit of an obscure issue, I have a workaround, but I want to debug it. I'm not sure where to start looking.
I'm using the `webrtc-native` GDNativeLibrary from: https://github.com/godotengine/webrtc-native
To allow native webrtc on windows/linux.
I've compiled the library from source. This supplies Godot with a native program for doing WebRTC calls outside of HTML5 builds. It does so by supplying native binary implementations for the Godot `WebRTCPeerConnection` and `WebRTCDataChannel` objects, via `WebRTCPeerConnectionGDNative` and `WebRTCDataChannelGDNative`.
The method `initialize(Dictionary options)` on `WebRTCPeerConnection` fails when calling from ECMAScript with the following error:
```
const peer = new godot.WebRTCPeerConnection();
peer.initialize({});
```
Output:
```
E 0:00:02.059 initialize: Condition "interface == __null" is true. Returned: ERR_UNCONFIGURED
modules/webrtc/webrtc_peer_connection_gdnative.cpp:74 @ initialize()
```
The `interface` variable is set in the `godot/modules/webrtc/webrtc_peer_connection_gdnative.cpp` class in the method `set_native_webrtc_peer_connection`, which is called by `godot/modules/gdnative/net/webrtc_gdnative.cpp` when a native implementation has been found, via a macro:
```
void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *p_impl) {
#ifdef WEBRTC_GDNATIVE_ENABLED
((WebRTCPeerConnectionGDNative *)p_obj)->set_native_webrtc_peer_connection(p_impl);
#endif
}
```
Now the reason I think this is a bug in the ECMAScript module is that if I create a GDScript file `webrtc_wrapper.gd`:
```
extends Node
func initialize(options: Dictionary) -> WebRTCPeerConnection:
var peer = WebRTCPeerConnection.new()
peer.initialize(options)
return peer
```
Set that GDscript as an Autoload singleton, and then call the following from my ECMAScript:
```
const webWrapper = this.get_node("/root/WebrtcWrapper");
const peer = webWrapper.call("initialize", {});
```
The `initialize` call executes correctly and I can continue to work with the returned `peer` object in ECMAScript.
So, for now, I have a workaround, but I'm puzzled why it's not working with ECMAScript, and wondered if someone could point me in the right direction, as I'm pretty new to GDNative and how it works. I wonder if for some reason the ECMAScript module is calling the unimplemented version of WebRTCPeerConnection rather than the GDNative version.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par reproduire l'appel ECMAScript et la comparaison avec le wrapper GDScript décrits dans l'issue. Lisez modules/webrtc/webrtc_peer_connection_gdnative.cpp et modules/gdnative/net/webrtc_gdnative.cpp, puis suivez comment set_native_webrtc_peer_connection est atteint ; le travail est terminé lorsque vous avez identifié pourquoi le chemin ECMAScript n'utilise pas l'implémentation native et confirmé le comportement corrigé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- cpp, javascript
- Domaine
- game-dev
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 30/100