Skip to content

Camera module not working on IOS 10 (only in devices) / It hangs and exit the app #2751

Closed

Description

@ignaciolarranaga

Tell us about the problem

I detected the problem on my app and later verified on the sample-iOS-CameraApp
I submitted a PR with the necessary changes to run (NativeScript/sample-iOS-CameraApp#15) but even that the application hangs at start.

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: 2.3.0
  • Cross-platform modules: 2.3.0
  • Runtime(s): 2.3.0
  • Plugin(s): N/A

Please tell us how to recreate the issue in as much detail as possible.

Just merge the PR and try to run the app on a device (Just confirmed it does not happen on the simulator, I tested on IPhone 6 / IOS 10.0.1).

Activity

  1. changed the title [-]Camera module hangs on IOS 10[/-] [+]Camera module hangs on IOS 10 (only in devices)[/+] on Sep 17, 2016
  2. modified the milestone: 2.4.0 on Sep 18, 2016
  3. ignaciolarranaga commented on Sep 21, 2016

    @ignaciolarranaga
    Author

    Guys some update on this ?

  4. changed the title [-]Camera module hangs on IOS 10 (only in devices)[/-] [+]Camera module not working on IOS 10 (only in devices) / It hangs and exit the app[/+] on Sep 27, 2016
  5. ignaciolarranaga commented on Sep 27, 2016

    @ignaciolarranaga
    Author

    @enchev @dtopuzov guys some expected release date for this ?, is blocking my release, please notice the application crash when activating the camera module, it is not just it doesn't work.
    Also I think it will happen in any updated IOS device (only tested in mine but seems to be related to the IOS version).

    Will appreciate any feedback.

  6. 3rror404 commented on Sep 29, 2016

    @3rror404

    The basic example from the documentation also crashes iOS 10.

    This is holding up my release too.

  7. valentinstoychev commented on Sep 29, 2016

    @valentinstoychev

    We are working actively on this and it should be live next week. @ignaciolarranaga, @3rror404 - is this OK for your release dates? Do we need to look for a workaround with the current implementation?

  8. added this to the 2.4.0 milestone on Sep 29, 2016
  9. SpoonIsBad commented on Sep 29, 2016

    @SpoonIsBad

    I was having this issue, adding:

    <key>NSCameraUsageDescription</key>
    <string>Some reason why you want to use the camera</string>
    

    to my Info.plist fixed it for me.

  10. 3rror404 commented on Sep 29, 2016

    @3rror404

    Hi @valentinstoychev, I've moved testing until early next week and set expectations for the missing feature. It would be amazing if there was some sort of workaround available before then but no worries if this isn't possible.

    @SpoonIsBad Adding the plist key allows the camera to open but tapping "Use photo" crashes the device. Did you experience this?

  11. SpoonIsBad commented on Sep 29, 2016

    @SpoonIsBad

    I'm actually using a QRCode module, so I don't have a "Use photo" option. I just noticed when I upgraded everything, the app was crashing whenever the QRCode module tried to use the camera, and adding the plist key fixed my problem.

  12. cfjedimaster commented on Sep 29, 2016

    @cfjedimaster

    I tried @SpoonIsBad 's suggestion, but no go. For me, my app doesn't crash, but cameraModule.takePicture() does nothing on a device. It does crash on the simulator.

  13. ignaciolarranaga commented on Oct 1, 2016

    @ignaciolarranaga
    Author

    I tried also @SpoonIsBad suggestion, it actually works for me (I take a picture and upload it to my servers without problems) but does not allow me to select pre-existing photos from the phone which I used to do in the past. It might be some change in the underlying API ? (seems it was that right?)

  14. 19 remaining items

  15. ignaciolarranaga commented on Oct 19, 2016

    @ignaciolarranaga
    Author

    I notice the image is also not resized as per the options given, i.e. the asset returned does not have the expected width/height in DIPs (nor in pixels). I validated this by logging once I get the imageSource (imageSource.width & imageSource.height).

  16. nsndeck commented on Oct 19, 2016

    @nsndeck

    Hi @ignaciolarranaga,

    Nativescript-camera plugin resizes images to the screen size of the device. We added this in order to prevent some big bitmaps (it results in a out of memory issue on android). So if you ask for an image size bigger than screen size result image will be with the size of the screen. Indeed you and @cfjedimaster are absolutely right about the missing documentation, but we have some other things to do. We plan to extend this image-asset class to provide methods for saving image to file. So there will be no need to use image-source workaround.
    About the non secured variable creationDate - I've made a small fix with version (0.0.4 of nativescript-camera plugin).

    Nedyalko

  17. ignaciolarranaga commented on Oct 19, 2016

    @ignaciolarranaga
    Author

    Thanks @nsndeck, but I was actually meaning that before the resize was to the width/height specified, not the screen size. For example, I had a code like this:

    let width = 1280 / platformModule.screen.mainScreen.scale;
    let height = 960 / platformModule.screen.mainScreen.scale;
    takePicture({ width: width, height: height, keepAspectRatio: false, saveToGallery: false })
        .then(picture => {
            let source = new ImageSource();
            source.fromAsset(picture)
                .then(imageSource => this.coverImage = imageSource);
            })
            .catch(error => console.log(error));
    

    but it is no longer valid, since the requested width/height are not taken into account. Am I right ?
    This is a little confusing because the CameraOptions does have width/height but it should have not if they are going to be ignored.

  18. 3rror404 commented on Oct 19, 2016

    @3rror404

    Custom width and height are definitely not working. I just tested with 300x300 and the image was saved at 2064x1161

  19. ignaciolarranaga commented on Oct 19, 2016

    @ignaciolarranaga
    Author

    @nsndeck, here is an example, I changed the code of the CameraTest in this way:

    export function onTakePictureTap(args: EventData) {
        let page = <Page>(<View>args.object).page;
        let saveToGallery = page.bindingContext.get("saveToGallery");
        takePicture({width: 180, height: 180, keepAspectRatio: false, saveToGallery: saveToGallery}).
            then((imageAsset) => {
                let source = new ImageSource();
                source.fromAsset(imageAsset).then(source => {
                    console.log("Size: " + source.width + "x" + source.height);
                });
                page.bindingContext.set("cameraImage", imageAsset);
            }, 
            (err) => {
                console.log("Error -> " + err.message);
            });
    }
    

    which should produce an square image, but says: CONSOLE LOG file:///app/main-page.js:25:24: Size: 375x667

    and here is how it looks:
    simulator screen shot oct 19 2016 10 41 03

    Just raised an issue for tracking: NativeScript/nativescript-camera#7

  20. nsndeck commented on Oct 19, 2016

    @nsndeck

    @ignaciolarranaga actually image-asset uses platformModule.screen.mainScreen.widthDIPS and heightDIPS to resize image. I've just saw a bug in the code of image-asset. I'll fix it and will test your scenario later today.

  21. ignaciolarranaga commented on Oct 21, 2016

    @ignaciolarranaga
    Author

    @nsndeck whenever you can please also check this issue: NativeScript/nativescript-camera#10 something strange happens and the gallery does not open on the device. I noticed it happens even if you just request the permissions (the application hangs)

  22. nsndeck commented on Oct 24, 2016

    @nsndeck

    Hi @ignaciolarranaga,

    You maybe already noticed that issue with custom image size has been resolved (completely for iOS and partly for Android). In order to resize the image on Android basically we have to create another bitmap (depending on size this could lead to Out-of-memory exception) therefore we postponed this a little bit to handle that scenario on native side (maybe immediately after the 2.4.0 release we will made necessary additions to tns-core-modules-widgets module).

    Nedyalko

  23. ignaciolarranaga commented on Oct 24, 2016

    @ignaciolarranaga
    Author

    Thanks @nsndeck ! Are the changes included in nativescript-camera-0.0.4 ?

  24. added and removed
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    on Nov 9, 2016
  25. removed their assignment
    on Nov 9, 2016
  26. lock commented on Aug 29, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  27. locked and limited conversation to collaborators on Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions