pablomatgar / Japanese-Sign-Language-Interpreter

Mobile application developed using Vue.js, Monaca, Framework7, Cordova and Teachable Machine, which recognises gestures from the Japanese Sign Language and converts them to Japanese text, with the possibility of translating them into English or Spanish.
MIT License
2 stars 3 forks source link

Issue when opening the app in iPhone #11

Closed pablomatgar closed 2 years ago

pablomatgar commented 2 years ago

Bug description

Sometimes, when the app is opened in iPhone (this bug is not occurring in Android), the camera is not displayed. If this happens, the camera will load when going to the settings page and back to the home page.

Bug screenshot:

IMG_7669

Correct behaviour

After opening the app, the camera will be displayed in the screen automatically. It should not be necessary to go to another page and back in order to make the camera work.

Correct behaviour screenshot (also after going to settings and back, if the bug occurs):

IMG_7671

How to reproduce

Using Monaca Custom Debugger, try to open the app in iPhone. Sometimes it will work properly, but sometimes it will not.

pablomatgar commented 2 years ago

I tried to solve it by adding some async/await and also, checking code from other users in Google, but I couldn't solve it.

yong-asial commented 2 years ago

@pablomatgar check this https://github.com/pablomatgar/Japanese-Sign-Language-Interpreter/pull/13/files

Basically, what we need to is to listen to onDeviceReady function

document.addEventListener('deviceready', () => {
  alert('deviceready');
  // all the plugin and cordova function are ready once this function finished (device is ready)
  // you can use this function in home.vue to start camera once the device is ready
}, false);

and only after that we can access all cordova functions and plugins without problems.

asial-matagawa commented 2 years ago

@pablomatgar @yong-asial I also tried to reproduce the problem.

the camera will load when going to the settings page and back to the home page.

In my environment, the camera was not loaded even after when going to the settings page and back to the home page.

I think there are more than one problem:

  1. We need to wait until window.plugin.CanvasCamera is loaded by using deviceready event. (as Yong-san said)
    • This will fix the problem that the camera is not loaded even if opening the settings page and close it.
  2. We need to fix some timing problem caused by asynchronous function calls.
    • This will fix the problem the camera will load when going to the settings page and back to the home page.

Please try 1 first 👍

pablomatgar commented 2 years ago

Thank you for your comments @yong-asial @asial-matagawa

I have solved the issue successfully.