Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black screen on second scan #35

Open
Noppey opened this issue Nov 25, 2022 · 4 comments
Open

Black screen on second scan #35

Noppey opened this issue Nov 25, 2022 · 4 comments

Comments

@Noppey
Copy link

Noppey commented Nov 25, 2022

Tested on Android (multiple devices such as Samsung S10e)

Everything runs great when scanning. After I've processed other stuff and navigate back to the component that holds the scanner. Everything is initialized again (tested with console.log):

onLoaded(args) {
    this.camera = args.object;
    this.requestPermission();
  }

  requestPermission() {
    this.camera.requestCameraPermission();
  }

However the MLKitView is black and doesn't do anything.
When pressing back (phone button) and navigating again to the scanner, everything starts working fine again.

<ActionBar [title]="'QRSCANNERTITLE' | L">
    <NavigationButton [text]="'BACK'| L"></NavigationButton>
</ActionBar>

<GridLayout rows="*, auto" height="100%">
    <MLKitView height="100%" [torchOn]="torchOn" cameraPosition="back" detectionType="all" (detection)="onDetection($event)" (loaded)="onLoaded($event)">

    </MLKitView>
    <Button row="1" height="40" [text]="torchOn ? ('TURNOFFTORCH' | L) : ('TURNONTORCH' | L)" (tap)="toggleTorch($event)"></Button>
</GridLayout>
@Noppey
Copy link
Author

Noppey commented Nov 25, 2022

Setting an *ngIf="initialized" works when setting this to false after scanning and true onInit. So there is an easy workaround.
But this shouldn't be necessary.

@triniwiz
Copy link
Member

@Noppey can you try with the latest version 1.0.7 and lmk if this is still an issue.

@boutier
Copy link

boutier commented Apr 12, 2023

I have a similar issue in 2.0.0.
Using some ngIf may fix the problem, but it was not that easy to find the good timing: having this in the ngInit was not sufficient, so what I currently do is something like:

<GridLayout (loaded)="switch2 = true">
  <MLKitView *ngIf="switch2" [...] ></MLKitView>
</GridLayout>

edit:

  • note that when I had a black screen, having a button to toggle the MLKitView (or any of its parents) does not allow to make it work again.

@nhuurnink
Copy link

nhuurnink commented Jun 10, 2024

After upgrading to 8.8.0-alpha the initialize ngIf workaround does not work anymore for me. What I did now is removed the *ngIf and just run this.myMLKitView.disposeNativeView(); when leaving the scanner. This works well so far when testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants