Fix réseau : file d'instanciation sur le thread de jeu (crash GL du TCPReader)
- Le TCPReader 2017 instaniait les prefabs réseau depuis son thread (pas de contexte OpenGL -> crash natif glGenTextures dès le premier prefab texturé) — bug jamais rencontré car le multi n'a jamais été testé à 2 - Network : pendingInstantiations (file) consommée par update() sur le thread de jeu - Test coop 2 clients desktop réels contre le matchmaker local : les 2 clients dans la même partie (game id=0), l'hôte instancie et envoie 36 objets réseau (lockers + player_other) ; handshake player_join du client restant partiel (protocole 2017 jamais testé à 2 — tracé TODO) - TODO/CHANGELOG mis à jour
This commit is contained in:
parent
6a250c192f
commit
a0d603d3d0
18
TODO.md
18
TODO.md
@ -182,6 +182,18 @@ reste du portage Android.
|
|||||||
(repo Matchmaking-Server, Node/UDP) fonctionne tel quel ; client
|
(repo Matchmaking-Server, Node/UDP) fonctionne tel quel ; client
|
||||||
configurable (env LS_MP_HOST/LS_MP_PORT desktop, PlayerPrefs
|
configurable (env LS_MP_HOST/LS_MP_PORT desktop, PlayerPrefs
|
||||||
mp_host/mp_port Android, défaut = serveur d'origine mort) ; test
|
mp_host/mp_port Android, défaut = serveur d'origine mort) ; test
|
||||||
desktop local E2E réussi (join → game_create → niveau multi chargé).
|
desktop local E2E réussi (join → game_create → niveau multi chargé)
|
||||||
Restant : test coop à 2 clients réels (émulateur zombie au moment du
|
- [x] Multi 2 clients réels — FAIT (v0.7.0, desktop×2 contre le matchmaker
|
||||||
test) + déploiement serveur au choix de l'utilisateur
|
local) : les 2 clients dans la MÊME partie (serveur : game id=0 avec 2
|
||||||
|
joueurs) ; fix majeur au passage : le TCPReader 2017 instaniait les
|
||||||
|
prefabs réseau depuis le thread réseau SANS contexte OpenGL (crash
|
||||||
|
natif glGenTextures) → file d'instanciation traitée sur le thread de
|
||||||
|
jeu (Network.handlePendingInstantiations) ; l'hôte instancie et envoie
|
||||||
|
36 objets réseau (lockers + player_other) au client
|
||||||
|
- [ ] Multi : handshake P2P restant — le client B ne reçoit pas le
|
||||||
|
player_join de l'hôte (direction des connexions TCP 2017 : l'hôte se
|
||||||
|
connecte à 2829/2830 au lieu du port TCP de B) — protocole jamais
|
||||||
|
testé à 2 chez les équipes d'origine ; à debugger avec les logs
|
||||||
|
(serveur + client)
|
||||||
|
- [ ] Test coop sur émulateur (client Android via 10.0.2.2) — BLOQUÉ : AVD
|
||||||
|
zombie (processus 91234 état UE, impossible à tuer sans redémarrage)
|
||||||
|
|||||||
@ -131,6 +131,9 @@ public class Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void update() {
|
private static void update() {
|
||||||
|
// Instanciations réseau reçues du TCPReader : à traiter SUR LE THREAD
|
||||||
|
// DE JEU (le thread réseau n'a pas de contexte OpenGL).
|
||||||
|
handlePendingInstantiations();
|
||||||
if (System.currentTimeMillis() >= lastUpdate + 1000 / UPDATES_PER_SECOND) {
|
if (System.currentTimeMillis() >= lastUpdate + 1000 / UPDATES_PER_SECOND) {
|
||||||
lastUpdate = System.currentTimeMillis();
|
lastUpdate = System.currentTimeMillis();
|
||||||
ByteBuffer data = ByteBuffer.allocate(
|
ByteBuffer data = ByteBuffer.allocate(
|
||||||
@ -434,7 +437,25 @@ public class Network {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File des instanciations reçues par le TCPReader : ce thread n'a PAS de
|
||||||
|
* contexte OpenGL (GLFW/GL 3.2 = un seul thread propriétaire) et crashait
|
||||||
|
* nativement (glGenTextures) dès qu'il instaniait un prefab avec textures
|
||||||
|
* — bug 2017 jamais vu car le multi n'a jamais été testé avec des prefabs
|
||||||
|
* texturés. La file est consommée par update() sur le thread de jeu.
|
||||||
|
*/
|
||||||
|
private static final java.util.ArrayList<String> pendingInstantiations = new java.util.ArrayList<>();
|
||||||
|
|
||||||
private static void processInstantiation(String message) throws IOException {
|
private static void processInstantiation(String message) throws IOException {
|
||||||
|
synchronized (pendingInstantiations) {
|
||||||
|
pendingInstantiations.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handlePendingInstantiations() {
|
||||||
|
synchronized (pendingInstantiations) {
|
||||||
|
while (!pendingInstantiations.isEmpty()) {
|
||||||
|
String message = pendingInstantiations.remove(0);
|
||||||
String[] split = message.split(SPLIT_DIVIDER);
|
String[] split = message.split(SPLIT_DIVIDER);
|
||||||
GameObject gameObject = PrefabManager.loadPrefab(split[0]);
|
GameObject gameObject = PrefabManager.loadPrefab(split[0]);
|
||||||
gameObject.networkId = Integer.parseInt(split[1]);
|
gameObject.networkId = Integer.parseInt(split[1]);
|
||||||
@ -452,6 +473,8 @@ public class Network {
|
|||||||
GameObject go = GameObject.instantiate(gameObject, position);
|
GameObject go = GameObject.instantiate(gameObject, position);
|
||||||
networkObjects.put(go.networkId, new InstantiationData(split[0], position, playerId, gameObject));
|
networkObjects.put(go.networkId, new InstantiationData(split[0], position, playerId, gameObject));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void destroy(GameObject gameObject) {
|
public static void destroy(GameObject gameObject) {
|
||||||
GameObject.destroy(gameObject);
|
GameObject.destroy(gameObject);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user