ionic-team / pwa-elements

Quality UI experiences for Web APIs that require custom UI (such as media/camera).
https://medium.com/@maxlynch/building-the-progressive-web-app-os-57daebcb69c1
MIT License
168 stars 50 forks source link

cancel photo click raise uncaught exception on web #104

Closed avallete closed 2 years ago

avallete commented 2 years ago

I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com

Current behavior: When taking a photo with capacitor in conjunction with "@ionic/pwa-elements", once the "validation" popup is show, an uncaught exception is thrown if you click on "cancel".

Expected behavior: On "cancel" clicked, we should go back to the "taking picture" mode.

Steps to reproduce: Here is a MRE demonstrating the bug: https://codesandbox.io/s/pedantic-kare-501iu?file=/src/App.tsx

Here is a screenrecording:

https://user-images.githubusercontent.com/8771783/145831597-8c6225e9-fd48-4b63-9e25-a59b949f5b09.mov

Related code:

I didn't had the time to investigate much, but seems like the issue occurs when we try to re-init the videoStream after cancel and the videoElement does not exist anymore: https://github.com/ionic-team/pwa-elements/blob/fb3f55e76ac1fc615323f9bf53033b540f2133c9/src/components/camera/camera.tsx#L330 https://github.com/ionic-team/pwa-elements/blob/fb3f55e76ac1fc615323f9bf53033b540f2133c9/src/components/camera/camera.tsx#L123