Comments (18)
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.
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.
Hi, @jacobweber . I was wondering if you had found a solution for this issue? Thanks.
from cordova-plugin-camera-preview.
@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.
@jacobweber's solution seems to have worked for me as well. Next to fix the slow startup ... :)
from cordova-plugin-camera-preview.
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.
Any chance of getting a fix for this?
from cordova-plugin-camera-preview.
Would still like to get this fixed if possible. Thanks.
from cordova-plugin-camera-preview.
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.
For me work on IOS 10, thanks @jacobweber
from cordova-plugin-camera-preview.
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.
@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.
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.
Hey, I see this is fixed in master. Are there plans to put this in a release soonish?
from cordova-plugin-camera-preview.
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.
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.
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.
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)
- Get color of touched pixel from camera preview HOT 1
- takeSnapshot return blank image HOT 1
- camera is taking entire screen height and flip and close,capture buttons are not visible in native device,Please let me know if anyone has solution for this,z index is already given same as in the code HOT 2
- is platform windows supported ? HOT 3
- is platform browser supported ? HOT 1
- error building with xcode 13.4.1 HOT 6
- How to add barcode scanning ability using another plugin?
- takePicture error only on Android 9
- How to disallow Screenshot
- Android Studio forces me to set android:exported="true" in AndroidManifest.xml HOT 1
- Image is saved as Base64 regardless of storeToFile setting
- Illegal Access HOT 1
- This plugin doesn't seem to install in Android 13, API 33 HOT 2
- takePicture does not resolve promise on iPhone 15 Pro HOT 4
- AVCaptureStillImageOutput' is deprecated: first deprecated in iOS 10.0 - Use AVCapturePhotoOutput instead.
- iPhone 13 Pro Max autofocus issue on close objects HOT 1
- Documentation wrong for takeSnapshot and takePicture
- Can not perform this action after onSaveInstanceState
- photos Android clearer
- how do i ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-camera-preview.