EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 442 forks source link

Camera view is black when unlocking phone or going back to app on Android #839

Open Tukkan opened 6 years ago

Tukkan commented 6 years ago

When having app opened, locking the phone (or when it's being automatically locked) and going back to the app after unlock or switching from the other app, the camera view from ML Kit is black on Android. iOS seems to work fine.

Pixney-William commented 6 years ago

I have seen this too.

Tukkan commented 6 years ago

Now in new version of plugin I can also see this behaviour when navigating back to screen when barcode scanner was used (tested on Android).

acrollet commented 5 years ago

possibly helpful: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1031#issuecomment-454580772

islam56naser commented 5 years ago

I'm also having this issue is there any update on this ?

dmdnkv commented 5 years ago

Any update on that issue? It also happens when navigating to the next screen and then going back with android back button or just switching apps and going back.

The workaround I used is the reinitialization of the component by using *ngIf and setTimeout around it and subscription to suspend\resume events of the app activity. Not a good way to resolve it but at least it helped.

kriefsacha commented 4 years ago

Any news on this ????

kriefsacha commented 4 years ago

It actually work now for me guys ! I had this issue for months, i did update to nativescript 6.0 and i have nativescript-firebase 9.0.2, and now it just work for IOS and Android ! I checked with the version i have in production (which is still in nativescript 5) and it doesn't work there so seems that it's the solution

timdoege commented 4 years ago

Just to pitch in for NativeScript 7 (and Angular 10), running version 11.1.3 of the plugin

The workaround for Android is currently to wrap the <MLKitBarcodeScanner>tag in a <ng-container *ngIf="loadScanner"> which is hidden on component initialization and activated using setTimeout fired off by the page loaded event (in a ngZone).

vallemar commented 3 years ago

I opened a similar problem https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1766 I have found the solution to this problem: I have implemented it in vue, they will have to pass it to angular:

  1. Force pause.
  2. Force the view with clearViewML.

Important: with v-if this doesn't work, it has to be v-show

<template>
             <MLKitBarcodeScanner
                        v-show="!clearViewML"
                        @loaded="loadedMLKitBarcodeScanner"
                        :pause="pause"
                          .
                          .
                          .
              >
              </MLKitBarcodeScanner>
</template>
<script>
export default {
    data() {
        return {
            ml: null,
            pause: false,
            clearViewML: false,
        };
    },

    methods: {
        loadedMLKitBarcodeScanner(args) {
            if (isAndroid) {
                if (this.ml == null) {
                    this.ml = args.object;
                } else {
                    this.pause = true;
                    this.clearViewML = true;
                    setTimeout(() => {
                        this.clearViewML = false;
                        this.pause = false;
                    }, 50);
                }
            }
        }
    }
};
</script>