nstudio / nativescript-camera-plus

MIT License
79 stars 50 forks source link

Create & destroy programmatically (slow bootup)? #37

Open keerl opened 6 years ago

keerl commented 6 years ago

Because the camera has such a slow start up time (a few seconds), page transitions are very delayed.

Is there a way to create the camera object programmatically, so that way I can transition to the new page smoothly then put up a loading window while the camera is booting up?

Also, is the camera object being destroyed when it is not visible (page change)? When I return to the camera page it is already there...so it either exists already or it loads extremely fast after the first load. If the same instance is still loaded is there a way to destroy it so I don't have a memory leak in my program?

bradmartin commented 6 years ago

I'm not sure on creating it programmatically, I'd say this is possible by just constructing a new instance in your code logic and then injecting that into the page when you want 👍

NS 3x (maybe a fix was in 4x) cached screens when you navigate away from so that when you go back all the instances shouldn't be reloaded. Sometimes there are bugs with some view components that cause memory leaks of course, but for the most part the 4x version of NS seems to not have any major ones as it's usually custom components or listview type controls that the leaks pop up in. At any rate hope this helps. If you need any help let me know. Thanks.

rohanrichards commented 6 years ago

I am using angular and simply used an ngIf='visible' property on the element. This has allowed me to defer the loading of the cam. The only downside is it is not cached after it is loaded, so each time you show/hide the cam by toggling this.visible, the camera has to boot up again (which as you know can take some time) You may be able to get around this by using ngIf only for the first load, then use some other property [visible]? to show/hide the cam element.