|
FORUMS PROFESSIONNELS WINDEV, WEBDEV et WINDEV Mobile |
| | | | | |
| Plantage application malgré cas erreur et cas exception |
| Débuté par erbl, 10 avr. 2026 09:38 - 3 réponses |
| |
| | | |
|
| |
Membre enregistré 273 messages |
|
| Posté le 10 avril 2026 - 09:38 |
Bonjour tout le monde
Gros soucis, tout est dans le titre (ou presque) Mon application plante de manière aléatoire (pas tout le temps, pas tous les utilisateurs, pas tous les appareils) lorsque l'utilisateur prend une photo (que ça soit via l'appel à cameraLAnceAppli ou via la fenêtre Camera)
Pourtant dans ma fonction Prendre_Photo j'ai bien un CAS ERREUR et un CAS EXCEPTION pour justement éviter que mon application ne s'arrête brusquement et fasse perdre du temps à mes utilisateurs
Au niveau de mes fichiers logs j'ai ça puis plus rien
09/04/2026 @ 10:02:13 > Parcours - Ouverture Photo 09/04/2026 @ 10:02:13 > Parcours - Photo - Mode natif
OU
09/04/2026 @ 09:25:23 > Parcours - Ouverture Photo 09/04/2026 @ 09:25:23 > Parcours - Photo - Mode application
Voici la procédure en question qui est appellé via un bouton de prise de photo dans l'application à plusieurs endroits
Procedure Prendre_Photo(champImage est un Champ, Image est une Image,suffixe est une chaîne)
sPhoto est une chaîne bGPhotoTermine est un booléen = Faux Log_Str ("Parcours - Ouverture Photo",#DEBUG_LEVEL_STANDARD)
SELON COL_VCI_Variables.gstMemory.nModePhoto CAS 1 Log_Str ("Parcours - Photo - Mode natif",#DEBUG_LEVEL_STANDARD) SI CaméraDemandePermission() = Vrai ALORS CaméraLanceAppli(viCaptureImage, CaméraLanceAppli_Callback) PROCEDURE INTERNE CaméraLanceAppli_Callback(sChemin est une chaîne) SI sChemin ~= "" ALORS bGPhotoTermine = Vrai RETOUR SINON sPhoto = sChemin FIN bGPhotoTermine = Vrai FIN TANTQUE bGPhotoTermine = Faux Wait_10ms_ByTimer(1000) FIN SI sPhoto<>"" ALORS Image = sPhoto CaméraGénèreMiniature(sPhoto,COL_VCI_Répertoires.gsLocal_PICT_Dir + suffixe + "_thumb.jpg",800,600) champImage = COL_VCI_Répertoires.gsLocal_PICT_Dir +suffixe + "_thumb.jpg" SINON SI PAS EnModeArrièrePlan() ALORS SI ErreurDétectée ALORS Erreur(ErreurInfo()) FIN FIN FIN FIN CAS 2 Log_Str ("Parcours - Photo - Mode application",#DEBUG_LEVEL_STANDARD) bAutoriseVideo est un booléen = Faux SI CaméraDemandePermission() = Vrai ALORS OuvreAsynchrone(FEN_Mobile_Camera_UI,(bAutoriseVideo),onCapture) PROCEDURE INTERNE onCapture(sCheminComplet <utile>) SI sCheminComplet<>"" ALORS sPhoto = sCheminComplet bGPhotoTermine = Vrai FIN FIN TANTQUE bGPhotoTermine = Faux Wait_10ms_ByTimer(1000) FIN Image = sPhoto CaméraGénèreMiniature(sPhoto,COL_VCI_Répertoires.gsLocal_PICT_Dir +suffixe + "_thumb.jpg",800,600) champImage = COL_VCI_Répertoires.gsLocal_PICT_Dir +suffixe + "_thumb.jpg" FIN AUTRE CAS Log_Str ("Parcours - Photo - Mode natif par défaut",#DEBUG_LEVEL_STANDARD) SI CaméraDemandePermission() = Vrai ALORS CaméraLanceAppli(viCaptureImage, CaméraLanceAppli_Callback) TANTQUE bGPhotoTermine = Faux Wait_10ms_ByTimer(1000) FIN SI sPhoto<>"" ALORS Image = sPhoto CaméraGénèreMiniature(sPhoto,COL_VCI_Répertoires.gsLocal_PICT_Dir + suffixe + "_thumb.jpg",800,600) champImage = COL_VCI_Répertoires.gsLocal_PICT_Dir +suffixe + "_thumb.jpg" SINON SI PAS EnModeArrièrePlan() ALORS SI ErreurDétectée ALORS Erreur(ErreurInfo()) FIN FIN FIN FIN FIN Log_Str ("Parcours - Fin Photo - "+sPhoto,#DEBUG_LEVEL_STANDARD) CAS ERREUR: sErrStr_Err est une chaîne = ErreurInfo() sErrStrSysteme_Err est une chaîne = ErreurInfo(errMessageSystème) sErrResume_Err est une chaîne = ErreurInfo(errRésumé) sErrCode_Err est une chaîne = ErreurInfo(errCode) sErrCodeSysteme_Err est une chaîne = ErreurInfo(errCodeSystème) sErrFichier_Err est une chaîne = ErreurInfo(errFichier) Log_Erreur("ERR fonction photo photo") Log_Erreur("ERR Code = " + sErrCode_Err) Log_Erreur("ERR Code systeme = " + sErrCodeSysteme_Err) Log_Erreur("ERR Resume = " + sErrResume_Err) Log_Erreur("ERR Message =" + sErrStrSysteme_Err) Log_Erreur("ERR Message systeme =" + sErrStr_Err) Log_Erreur("ERR Fichier = " + sErrFichier_Err) CAS EXCEPTION: sErrStr est une chaîne = ExceptionInfo() sErrStrSysteme est une chaîne = ExceptionInfo(errMessageSystème) sErrResume est une chaîne = ExceptionInfo(errRésumé) sErrCode est une chaîne = ExceptionInfo(errCode) sErrCodeSysteme est une chaîne = ExceptionInfo(errCodeSystème) sErrFichier est une chaîne = ExceptionInfo(errFichier) Log_Erreur("XCPT fonction photo") Log_Erreur("XPCT Code = " + sErrCode) Log_Erreur("XPCT Code systeme = " + sErrCodeSysteme) Log_Erreur("XPCT Resume = " + sErrResume) Log_Erreur("XPCT Message =" + sErrStrSysteme) Log_Erreur("XPCT Message systeme =" + sErrStr) Log_Erreur("XPCT Fichier = " + sErrFichier)
-- Ce n'est pas l'outil le plus important mais la manière de s'en servir |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 316 messages |
|
| Posté le 10 avril 2026 - 10:05 |
Bonjour,
Tu n'as pas précisé si le plantage se produit sur Android ou iOS
Cela dit, j'ai déjà rencontré ce problème sous Android. C'est la fonction CaméraDemandePermission() qui provoquait ce plantage aléatoire.
J'ai contourné ce problème en utilisant PermissionDemande(permCaméra) https://doc.pcsoft.fr/fr-FR/?1410087423&name=PermissionRequest
Petite précision : je n'utilise pas de procédure callback avec CaméraLanceAppli() Je ne sais pas ce que fait ta fonction Wait_10ms_ByTimer(1000) à l'intérieur de la boucle TANTQUE, mais il y a une forte probabilité que l'application bloque à ce niveau là
Pour iOS je ne pourrais pas t'aider. Navré
CdltMessage modifié, 10 avril 2026 - 10:16 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 273 messages |
|
| Posté le 10 avril 2026 - 10:59 |
Bonjour et merci pour ce retour , effectivement cela se produit sur Android La fonction est un simple timer qui est utilisé régulièrement dans l'application quand necessaire
Procedure Wait_10ms_ByTimer (n10ms) nN est un entier
SI nTimerWait_10mS > 0 ALORS RETOUR FIN
bWait10mSStop = Vrai nTimerWait_10mS = TimerSys(Wait_Timer_100mS,n10ms) nN = nTimerWait_10mS SI nTimerWait_10mS > 0 ALORS TANTQUE (bWait10mSStop = Vrai ET nN) <Compile SI PAS TypeConfiguration=UniversalWindowsApp> Multitâche(-1) <FIN> nN -= 1 FIN SI nN = 0 ALORS FinTimerSys(nTimerWait_10mS) nTimerWait_10mS = 0 FIN FIN
-- Ce n'est pas l'outil le plus important mais la manière de s'en servir |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 316 messages |
|
| Posté le 10 avril 2026 - 11:34 |
Bonjour,
L'utilisation de Multitache() n'est pas recommandé sous Android s'il y a des actions (clic sur l'écran par ex)
As-tu réellement besoin d'utiliser une fonction callback avec CaméraLanceAppli() ? Est-ce nécessaire pour l'application pour des threads secondaires ou autre ? Si ce n'est pas le cas, je te suggère de faire plus simple :
sPhoto = CaméraLanceAppli(viCaptureImage) SI ErreurDétectée ALORS SI PAS EnModeArrièrePlan() ALORS Erreur(ErreurInfo()) RETOUR FIN SI sPhoto<>"" ALORS Image = sPhoto CaméraGénèreMiniature(sPhoto,COL_VCI_Répertoires.gsLocal_PICT_Dir + suffixe + "_thumb.jpg",800,600) champImage = COL_VCI_Répertoires.gsLocal_PICT_Dir +suffixe + "_thumb.jpg" FIN
CdltMessage modifié, 10 avril 2026 - 11:49 |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|