Giter Club home page Giter Club logo

Comments (18)

jacobweber avatar jacobweber commented on May 29, 2024 2

This is easier to reproduce if I start the camera, switch to the back-facing camera, then stop the camera. I can only reproduce it on a real device; not a simulator.

I notice that it's calling [self.sessionManager.session stopRunning] twice:

  • In CameraPreview's stopCamera method, it first removes the view. This causes CameraRenderController's viewWillDisappear method to be called, which calls stopRunning.
  • Then the stopCamera method calls stopRunning directly.

This second call seems to cause the delay. If I comment it out, I don't see the delay. But I don't know if this would have any other side-effects. What do you think?

from cordova-plugin-camera-preview.

p3v9d5ui avatar p3v9d5ui commented on May 29, 2024 1

I've tried every suggestion here, including @jacobweber 's and using the latest from master. Nothing has made any difference. @shadowjohn -- I don't understand your comment. Is there some change in the code you've pasted? It looks the same as what is in the package.

Has this really been resolved for others? Even with the current master?

from cordova-plugin-camera-preview.

starsasumi avatar starsasumi commented on May 29, 2024

Hi, @jacobweber . I was wondering if you had found a solution for this issue? Thanks.

from cordova-plugin-camera-preview.

jacobweber avatar jacobweber commented on May 29, 2024

@starsasumi: The thing I suggested above seems to work, but I'd like to hear from @mbppower to be sure.

from cordova-plugin-camera-preview.

rsekhar avatar rsekhar commented on May 29, 2024

@jacobweber's solution seems to have worked for me as well. Next to fix the slow startup ... :)

from cordova-plugin-camera-preview.

Fenkiou avatar Fenkiou commented on May 29, 2024

I was having this problem too. But today after a rebuild, the camera is starting and stopping really fast as normal I think.

I'm on iOS 9 Public Beta and OS X Public Beta and use Xcode 7 beta 6 (not the latest : 7)

Hum.. after some tests, the start time is the same but the first time I close the camera, it's long and next times it's fast. I don't know why.

from cordova-plugin-camera-preview.

jacobweber avatar jacobweber commented on May 29, 2024

Any chance of getting a fix for this?

from cordova-plugin-camera-preview.

jacobweber avatar jacobweber commented on May 29, 2024

Would still like to get this fixed if possible. Thanks.

from cordova-plugin-camera-preview.

rafaelbuiu avatar rafaelbuiu commented on May 29, 2024

It keeps taking a lot to resume the normal functioning even after removing the mentioned code line.
Does anyone found a fix for this?

I am using ionic 2, by the way.

from cordova-plugin-camera-preview.

Xwalk-Company avatar Xwalk-Company commented on May 29, 2024

For me work on IOS 10, thanks @jacobweber

from cordova-plugin-camera-preview.

Tawsif avatar Tawsif commented on May 29, 2024

Thanks @jacobweber this works for me too for now. if this solution is a feasible one or If any better solution is found then please let us know.

from cordova-plugin-camera-preview.

gorghoa avatar gorghoa commented on May 29, 2024

@erperejildo, why closing this issue ? the issue still affects my project, have I missed a workaround ?

Got this this morning:

Groww[758:144358] THREAD WARNING: ['CameraPreview'] took '9003.186035' ms. Plugin should use a background thread.

from cordova-plugin-camera-preview.

shadowjohn avatar shadowjohn commented on May 29, 2024

Try modify plugins/CameraPreview.m
Fix the slow issue.


  • (void) stopCamera:(CDVInvokedUrlCommand*)command {
    [self.commandDelegate runInBackground:^{ //Add by 3WA
    NSLog(@"stopCamera");
    CDVPluginResult *pluginResult;
    if(self.sessionManager != nil) {
    [self.cameraRenderController.view removeFromSuperview];
    [self.cameraRenderController removeFromParentViewController];
    self.cameraRenderController = nil;
    [self.sessionManager.session stopRunning];
    self.sessionManager = nil;
    pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
    }
    else {
    pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Camera not started"];
    }
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
    }]; //Add by 3WA
    }

from cordova-plugin-camera-preview.

chris-held avatar chris-held commented on May 29, 2024

Hey, I see this is fixed in master. Are there plans to put this in a release soonish?

from cordova-plugin-camera-preview.

westonganger avatar westonganger commented on May 29, 2024

Going to be a while longer before another release, lots of fixes coming in fairly often. Just use master please.

from cordova-plugin-camera-preview.

shadowjohn avatar shadowjohn commented on May 29, 2024

Just add runInBackground 2 lines below.
fix stopCamera stuck a while.

(void) stopCamera:(CDVInvokedUrlCommand*)command {
[self.commandDelegate runInBackground:^{ //Add by 3WA (different here)

code
code
code
...

}]; //Add by 3WA (different here)
}

aca2424#diff-348cd740fd42e865011dc8c40cf64fe7

from cordova-plugin-camera-preview.

p3v9d5ui avatar p3v9d5ui commented on May 29, 2024

Updated: So the latest from master does, in fact, appear to be working for me. It looks like it was really a DOM update which was making it appear like the stopCamera() process was taking so long.

from cordova-plugin-camera-preview.

novicailievski93 avatar novicailievski93 commented on May 29, 2024

The update that is in the latest master seems that is not working for me. I solved this issue by calling the hide() method.

Here's an example of the implementation:

backButton(): Promise<any> {
    this.cameraPreview.hide().then(() => {
      this.navCtrl.pop();
      this.cameraPreview.stopCamera();
  });
}

What I am doing here is hiding the camera, without worring if the promise stopCamera() is resolved (takes 10s. in approx. 1/7 times) or not.

The app was crashing when opening the camera again in the span of those 10s. the promise from above needed to resolve. Because of that before every start of the camera I'm invoking the stopCamera() promise as a checkup if the previous is not finished.
You don't need to worry if the stopCamera() is called even though the camera is stopped, it causes Unhandled Promise rejection, but if the previews stopCamera() from backButton() method is not finished, it is invoked and resolved again.

onCameraOpen(): Promise<any> {
  this.cameraPreview.stopCamera();
  this.cameraPreview.startCamera();
}

It is a bit hacky, but it works for me for now until the plugin is updated with a solution for this.

from cordova-plugin-camera-preview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.