Page refresh after CameraPreview.stopCamera() doesn't work properly

Hi guys,

I implemented an App which predicts the input of the CameraPreview with Tensorflow.js and when an object is found it should disable the camera and show a text. Here is the sourcecode Im using right now

  <div *ngIf="stateOfApp == State.START">
    <ion-button (click)="startCamera()">Start Scan</ion-button>
  <div *ngIf="stateOfApp == State.SCAN">
    <!-- nothing is shown here, just the camera preview screen -->
  <div *ngIf="stateOfApp == State.RESULT">
    <p>Found image</p>

 async startCamera() {
    this.stateOfApp = State.SCAN;
    await this.cameraPreview.startCamera(this.cameraPreviewOpts);
    requestAnimationFrame(() => {

  async predictionLoop() {
    const imageAsBase64 = await this.cameraPreview.takeSnapshot({ quality: 60 });
    this.aiService.predictImage(imageAsBase64).then(result => { // predictImage(string) returns Promise<boolean>
      if (result) {
        // if the image is found result == true, works fine until here
      } else {
        requestAnimationFrame(() => {

  takePicture(): void {
      (imageData) => {
        this.stateOfApp = State.RESULT; // state is set correctly, but the page doesn't show the text
        this.sendImageToServer(imageData); // works also nice
      (err) => {

Do you have any idea how to fix the problem that the

tag for the state RESULT is not shown/refreshed properly?

Thanks in advance!

While you wait for better answers, what I would do is make a mock CameraPreview that has roughly the same public-facing shape, and see if your problem persists even when using it.

100 open issues, many several years old, and a prominent warning in the README that one shouldn’t rely on public releases, but instead try to track the master branch? Signs that I would consider “I might not be able to rely on this plugin”. I’m not saying I know it’s the plugin’s fault, but it would be nice to be able to definitively say one way or another.

Thanks for your answer. Yes I’m using the master branch in my app.
I got a workaround by calling
after changing the state. It’s strange that I need to call the detectChanges() every time changing the state, maybe the ChangeListener is killed but reattaching it via ChangeDetectorRef.reattach() does not help

I think my problem is caused by the following bug: