Search Unity

NatDevice - Media Device API

Discussion in 'Assets and Asset Store' started by Lanre, Dec 17, 2015.

?

Should we add exposure controls in v1.3? This means dropping support for iOS 7

Poll closed Jun 10, 2016.
  1. Yes

    9 vote(s)
    75.0%
  2. No

    3 vote(s)
    25.0%
  1. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    This error happens because of NatShare. You need to update your Android SDK build tools to 29.
     
  2. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    Oh Is there a way to go back to build Android SDK version 22? Because I think your settings say you need SDK 22 or higher, can you refund the fee if not?

    upload_2020-4-13_13-7-55.png
     
  3. fredmouse

    fredmouse

    Joined:
    Oct 22, 2017
    Posts:
    5
    Hi,Lanre. Firstly, I have to say it was my bad not to use the latest NatCorder(1.5). However I have upgraded to 1.7.1 and the problem is still there.I haven't bought the NatDevices yet so I'm still using NatMic 1.3.3. Below is the code after being upgraded to 1.7.1. With the upgrade it pops up 2 new problems while the old problem remains. One is that there is a green line on right edge of recorded videos. Another is that I have two cameras being streaming to the NatCorder which are in the array RecordCamera as you can see below, but only the first camera is recorded. BTW I'm using Unity 2019.1.13f. Is it a version problem or just my code problem.
    Code (CSharp):
    1.  public void StartRecording () {
    2.             // Start recording
    3.          
    4.             if (Screen.width>Screen.height)
    5.             {
    6.                 videoWidth = 1280;
    7.                 videoHeight = (int)((float)videoWidth / (float)Screen.currentResolution.width *
    8.                        (float)Screen.currentResolution.height);
    9.             }
    10.             else
    11.             {
    12.                 videoHeight = 1280;
    13.                 videoWidth = (int)((float)videoHeight / (float)Screen.currentResolution.height *
    14.                        (float)Screen.currentResolution.width);
    15.             }
    16.             Debug.Log("camera videoWidth " + videoWidth + " videoHeight " + videoHeight);
    17.  
    18.             var sampleRate = 44100;
    19.             var channelCount = 2;
    20.          
    21.             recordingClock = new RealtimeClock();
    22.             videoRecorder = new MP4Recorder(
    23.                 videoWidth,
    24.                 videoHeight,
    25.                 30,
    26.                 sampleRate,
    27.                 channelCount
    28.  
    29.             );
    30.  
    31.             // Create recording inputs
    32.             cameraInput = new CameraInput(videoRecorder, recordingClock, RecordCameras);
    33.             audioDevice = AudioDevice.GetDevices()[0];
    34.             audioDevice.StartRecording(sampleRate, channelCount, this);
    35.  
    36.         }
    37.  
    38.  public async void StopRecording () {
    39.             // Stop the recording inputs
    40.             if (recordMicrophone) {
    41.                 //StopMicrophone();
    42.                 //audioInput.Dispose();
    43.             }
    44.            
    45.  
    46.             audioDevice.StopRecording();
    47.             cameraInput.Dispose();
    48.             // Stop recording
    49.             IsPaused = false;
    50.             var path = await videoRecorder.FinishWriting();
    51.             // Playback recording
    52.             Debug.Log($"Saved recording to: {path}");
    53.             OnReplay(path);
    54.         }
    55.  
    56.  public void OnSampleBuffer(float[] sampleBuffer, int sampleRate, int channelCount, long timestamp)
    57.         {
    58.             videoRecorder.CommitSamples(sampleBuffer, recordingClock.timestamp);
    59.         }
    60.  
     
    Last edited: Apr 13, 2020
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    As I mentioned, this has nothing to with NatDevice. It is a NatShare issue. And the fix for you is to update the Android SDK build tools to version 29. The build tools version is not the same thing as the minimum SDK build level, which is what you seem to be conflating. A Google search is a good start.
     
  5. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Please post on the NatCorder forum thread. This thread is for NatDevice. A green line indicates padding, which some encoders do when the video dimensions are not standard numbers. Record at 1280x720 instead of calculating the recording height dynamically and the line should disappear. As for your multiple cameras, make sure that your cameras render properly in the scene (read up on the clearing mode for the camera).
     
  6. Mukaujoka

    Mukaujoka

    Joined:
    Mar 17, 2017
    Posts:
    17
    Hello Lanre,

    I recently started using NatDevices Microphone functionality and noticed that the first time I record something I get the following error:



    This does not only happen in my scene and implementation but also in the HotMic example. I'm using Unity 2019.2.21f1, NatDevice is updated to it's current version, XCode is on the most recent version and I run the examples on an iPhone SE with iOS 13.4.

    This only happens the first time, every following recording works flawlessly.
     
  7. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I'll look into this. Thanks for bringing it to my attention.
     
  8. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    Do you mean that you can only use Android SDK 29? Then this plugin is completely useless for our company, I need a version that can be used in Android SDK 22. If not, I want to refund
     
  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    As I said before, the build tools version is not the same thing as the minimum SDK build level. Please take a moment to re-read my post, and follow the link. I'm sure you'll find a simple Google search to be very insightful.
     
  10. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    I know that building apk minimum SDK build level 29 is successful, but my apk requires the target device to be above minimum SDK build level 23, how can I do it?
     
  11. Claude_V

    Claude_V

    Joined:
    Apr 16, 2013
    Posts:
    31
    I am putting my issue back on the table.... on Android (we test on BV5500 devices) when passing the device to sleep mode and back, at a certain point "deviceQuery.currentDevice is CameraDevice device" becomes false.

    Is there a way, if this happens, that I destroy and clean up and call "deviceQuery = new MediaDeviceQuery(MediaDeviceQuery.Criteria.GenericCameraDevice);" again ?

    I have no clue how to stop the NatDevice camera things and restart it properly.

    I also have no idea why this is happening. It's rare and it appears to happen only when switching the device on and off and reusing the app.

    Thanks for the help.
     
  12. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    You can't destroy a device query because you don't need to. I'm a bit confused though, what do you mean by passing the device to sleep mode? If you are shutting down the device itself, then all open apps will close. If you are simply suspending the app, then this has nothing to do with the device query. Maybe you are resetting the device query somewhere in your code, unknown to you.
     
  13. Claude_V

    Claude_V

    Joined:
    Apr 16, 2013
    Posts:
    31
    Not shutting down. Putting the device to "sleep" ... either by pressing the button or by waiting until it passes to sleep itself. So the app is just in the background...
    The app isn't doing any fancy stuff. It's just a UI interface with external api calls. I am not resetting the device query and the code is exactly like the demo that comes with NatDevice.

    I have requested additional testing on the app... let's wait and see if they come back with logcat results
     
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    If the app loses focus then NatDevice will pause any camera device that is running. The media device query is in no way affected by this.
     
  15. yogi_kenobi

    yogi_kenobi

    Joined:
    May 24, 2017
    Posts:
    23
    Hi!

    The link to documentation on the first page if this thread seems to be broken. Can anyone confirm

    a) Is it possible to grab frames from supported camera device and convert those into Unity's Texture2D type?
    b) If yes, is that how performant compared to using Unitys WebCamTexture and turning those into Texture2d (not performant at all).
     
  16. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I'm working on updated documentation, so it's very much a work-in-progress but check it out anyway.
     
  17. yogi_kenobi

    yogi_kenobi

    Joined:
    May 24, 2017
    Posts:
    23
    I ended up buying this asset now as I guess I have to try this out to see of it's speedier than working with WebCamTexture.

    My problem is that I can't figure out how to open straight away a specific (web)camera device either by name or index. Is it supported?
     
  18. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Use `MediaDeviceQuery` to find devices. Look at the README for more info.
     
  19. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    Hi Lanre If NatDevice-Media Device API for opencvforunity is currently only available in SDK 29 and above, please reply if I want to refund
     
  20. brzzda

    brzzda

    Joined:
    Jun 6, 2019
    Posts:
    1
    Hi Lanre,
    I have run into a problem with memory leak. In my project I am using ArFoundation for camera tracking and occasionally I need to take a picture with the highest possible resolution, so switching from NatDevice to ARSession and back is necessary. I have kept it simple: turn off ARSession, turn on NatDevice, take a picture, turn off NatDevice, turn on ARSession (see the code below). However, after taking several (20-25) pictures the application is crushing due to memorry issues. When running with profiler the application allocates extra 30MB of memory with each taken picture and eventually reaches the maximum (1420MB) and terminates.

    Code (CSharp):
    1. private CameraDevice _nativeCamera;
    2.  
    3. private async void StartNativeCamera()
    4. {
    5.     bool cameraPermissionGranted = await MediaDeviceQuery.RequestPermissions<ICameraDevice>();
    6.     if (cameraPermissionGranted)
    7.     {
    8.         var query = new MediaDeviceQuery(
    9.             device => device is ICameraDevice
    10.         );
    11.         _nativeCamera = query.currentDevice as CameraDevice;
    12.     }
    13. }
    14.  
    15. public void TakeSnapshot()
    16. {
    17.     _nativeCamera.previewResolution = (3264, 2440);
    18.     _nativeCamera.photoResolution = (3264, 2440);
    19.     ARSession.enabled = false;
    20.     await _nativeCamera.StartRunning();
    21.     await Task.Delay(10);
    22.     Texture2D imgTexture = await _nativeCamera.CapturePhoto();
    23.     Destroy(imgTexture);
    24.     _nativeCamera.StopRunning();
    25.     ARSession.enabled = true;
    26. }
    Am I doing something wrong? I have a feeling like I am missing something essential here.

    Observations:
    - When taking single picture, the memory temporarily allocates several 30MB blocks (up to 25). The number of these extra blocks then drops down to "expected" (still not doable) value (one block per taken picture).
    - Commenting out the line with CapturePhoto() method results in no memory leak (no extra 30MB memory blocks allocated at all).

    setup:
    Unity 2019.3.0f6, ARFoundation 3.1.0, iPad 6 - iPadOS 13.4.1, xcode 11.3.1
     
    wesense likes this.
  21. musicdeveloper

    musicdeveloper

    Joined:
    Oct 16, 2019
    Posts:
    68
    Hello, just upgraded my project from NatMic to NatDevice... just using NatDevice to do a simple audio recording using the code provided in HotMic.
    Everything works great during testing.

    - A user sent me a .wav recorded in the updated version of the app that sounds like it's running at about 50% speed, and lower in pitch than it should be.
    I think this can potentially be caused by sample rate confusion somewhere? Maybe the user is using an audio device that's telling the app to record at a weird sample rate?

    The NatDevice HotMic example gets the sample rate from the input device - my instinct is that maybe I should instead lock it down to 44100 - though maybe this will just create more issues?

    The code I'm currently using to set up the recording is:
    Code (CSharp):
    1. audioRecorder = new ClipRecorder(audioRecordingDevice.sampleRate, audioRecordingDevice.channelCount);
    I'm wondering if maybe it would be a safer bet to use:
    Code (CSharp):
    1. audioRecorder = new ClipRecorder(44100, audioRecordingDevice.channelCount);
    Do you have any advice?
    Thank you.

    (Just for reference, the old version of my app had used this code for NatMic, with the sample rate locked):
    Code (CSharp):
    1. audioRecordingDevice.StartRecording(
    2.                     44100,          // Requested sample rate
    3.                     2,              // Requested channel count
    4.                     wavRecorder     // Audio data receiver
    5.                 );
     
  22. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Can you share your full camera code? You seemed to have pasted in pseudocode (I can tell because you are calling `await` in a method not marked as `async`, which will not compile). I'll try to reproduce on my end.
     
  23. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    What platform does this happen on?
    It depends on whether you're running on iOS actually; all other platforms will work fine with a hard-coded sample rate. On iOS, setting the sample rate on the device will send the request to the system (iOS encapsulates system-wide audio configuration in it's AVAudioSession). Before NatDevice would ignore any request to set the sample rate of the audio device because we weren't sure of the effect on any other audio services (like Unity's FMOD audio engine), but we've changed this to set it anyway. I'm just not sure if this change is live on the Asset Store (gotta check).
     
  24. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    As I've explained, this is not a NatDevice issue (it is an issue with NatShare). And the workaround is to update your Android SDK's build tools to 29 or 30.
     
  25. musicdeveloper

    musicdeveloper

    Joined:
    Oct 16, 2019
    Posts:
    68
    - The user was running on MacOS.

    - Ok - I guess just confirm if you think that hardcoding the sample rate might help avoid the generated AudioClip coming out slower or lower in pitch than intended? Is there anything else that could be causing that?
     
  26. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    Okay, you did n’t make it clear on the product, and you are willing to refund the money? It ’s really bad. Dishonest businessman
     
    Last edited: Apr 20, 2020
  27. Claude_V

    Claude_V

    Joined:
    Apr 16, 2013
    Posts:
    31
    Hi Lanre,

    We have tested our App, using NatDevice, a lot now and today the camera crash appeared again.
    Maybe you will be able to make something up from the logcat... maybe I am doing something wrong ?

    Thanks for your feedback !

    04-21 14:06:33.430 527 4098 I Camera3-Device: disconnect: E
    04-21 14:06:33.431 31874 31874 E NatSuite: NatDevice Error: Camera 0 failed to stop preview
    04-21 14:06:33.431 31874 31874 E NatSuite: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.camera2.CameraCaptureSession.stopRepeating()' on a null object reference
    04-21 14:06:33.431 31874 31874 E NatSuite: at api.natsuite.natdevice.CameraDevice.stopRunning(CameraDevice.java:478)
    04-21 14:06:33.431 31874 31874 E NatSuite: at api.natsuite.natdevice.CameraDevice$2.onError(CameraDevice.java:462)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.notifyError(CameraDeviceImpl.java:1900)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.lambda$Sm85frAzwGZVMAK-NE_gwckYXVQ(Unknown Source:0)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.hardware.camera2.impl.-$$Lambda$CameraDeviceImpl$CameraDeviceCallbacks$Sm85frAzwGZVMAK-NE_gwckYXVQ.accept(Unknown Source:8)
    04-21 14:06:33.431 31874 31874 E NatSuite: at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:258)
    04-21 14:06:33.431 31874 31874 E NatSuite: at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:182)
    04-21 14:06:33.431 31874 31874 E NatSuite: at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:77)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.os.Handler.handleCallback(Handler.java:873)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.os.Handler.dispatchMessage(Handler.java:99)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.os.Looper.loop(Looper.java:193)
    04-21 14:06:33.431 31874 31874 E NatSuite: at android.app.ActivityThread.main(ActivityThread.java:6724)
    04-21 14:06:33.431 31874 31874 E NatSuite: at java.lang.reflect.Method.invoke(Native Method)
    04-21 14:06:33.431 31874 31874 E NatSuite: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    04-21 14:06:33.431 31874 31874 E NatSuite: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
    04-21 14:06:33.431 31874 31874 E NatSuite: NatDevice Error: CameraDevice 0 encountered error:3
    04-21 14:06:33.538 548 5263 D SeninfDrvImp: [configMclk][configMclk] Tg0clk: 24 pcEn = 0
    04-21 14:06:33.538 548 5263 D SeninfDrvImp: [configMclk]mclk0: 24, clkCnt1: 0 pclkInv 0
    04-21 14:06:33.539 548 5263 D SeninfDrvImp: [setMclk1][setMclk1]pcEn(0), clkPol(0), mMclk1User(0), TimestampClk(11), SENINF_TG1_PH_CNT(0x5), mclkSel 24
    04-21 14:06:33.539 548 5263 D SeninfDrvImp: [uninit][uninit]: 1
    04-21 14:06:33.539 548 5263 D SeninfDrvImp: [uninit][uninit]: 0, mfd(21)
    04-21 14:06:33.542 548 5263 D paramctrl_lifetime: [+uninit]
    04-21 14:06:33.542 548 5263 D ispdrv_mgr: [uninit()] - E. m_Users: 1
    04-21 14:06:33.557 548 5263 D AppTsf : [TsfExit] TsfExit
    04-21 14:06:33.557 548 5263 D AppTsf : [~AppTsf] destructor
    04-21 14:06:33.558 548 5263 D tsf_core: [~TsfCore] destructor
     
  28. MultivariousDev01

    MultivariousDev01

    Joined:
    May 22, 2014
    Posts:
    28
    You know that the Build Tools SDK isn't the same thing as the target player Android SDK, right? Is there some reason you can't update your compiler SDK? https://stackoverflow.com/questions...-sdk-version-target-sdk-version-vs-compile-sd You shouldn't lose any target platforms by Lanre's suggestion.

    Anyway, hey Lanre, I have an iOS 12.2 on an iPhone 8 user who's experiencing a crash with our app. I'm not sure if it's NatDevice or GoogleVR where the crash is coming from. We've only been able to trace it at a pretty low level. Specifically in XCode it seems to be happening here

    Code (CSharp):
    1. IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Bridge_CameraDevices_m56EF2D84FE24C93077E35C6A63EDD90D490F3540 (intptr_t* ___outDevicesArray0, int32_t* ___outDevicesArrayCount1, const RuntimeMethod* method)
    2.  
    3. {
    4.        typedef void (DEFAULT_CALL *PInvokeFunc) (intptr_t*, int32_t*);
    5.        // Native function invocation
    6.        reinterpret_cast<PInvokeFunc>(NDCameraDevices)(___outDevicesArray0, ___outDevicesArrayCount1);
    7. }
    I'm still trying to trace and find out more. Everything seems fine on iOS 13. Just curious if you knew of anything offhand that could affect iOS 12, or any known issues being alongside the Google VR For Unity plugin?

    We are pretty sure it is coming from GVR. But we aren't likely to get any replies from them any time soon. The issue seems related to GvrAudio_Initialize_m2441973946

    They also sent me this
    Turned out that there was an incompatibility between two different libraries (which maybe you don’t use, or maybe you do?) and they were recommending downgrading to a particular set of version numbers, or waiting for the next update. This was from 2017 so, the exact same issue is probably not still an issue, but it might point you to something? I couldn’t find any online help for NDCameraDevices returning a EXC_BAD_ACCESS crash. But, I’ll keep looking. Here is the report for what it is worth (look for the section with a workaround FIX, which I tried, but it didn’t help):

    https://github.com/googlevr/gvr-unity-sdk/issues/665

    I'm guessing I need to dig around in Google VR's guts... I'm just confused as to what's breaking it and why everything seems to work fine on iOS 13 but not on iOS 12.

    Appreciate all you do! Was a NatCam owner but was totally happy to repurchase NatDevice in order to access the 1.0.1 update, since we'd been benefiting from NatCam for years. So far have been loving the new version.
     
    Last edited: Apr 21, 2020
    Lanre likes this.
  29. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Yeah you can try that. I wasn't able to reproduce this behaviour on my end.
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    You still seem to have a misunderstanding. The gradle issue has nothing to do with NatDevice. It is because of a fix in NatShare, and NatShare is open source.
     
  31. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Can you share your camera code? You shouldn't actually get a crash, because NatDevice catches any errors and instead logs it.
     
  32. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    I know that, as you said, NatShare requires SDK 29 or more, but I bought your NatDevice just to use OpenCVforUnity. It also involves NatShare, and your instructions also say Android API level 22+, but it does n’t work anymore. The method is used on Android API level 22 or higher, so it is not your mark error?
     

    Attached Files:

  33. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey thanks for your support! For the crash you're facing, do you have the call stack in Xcode (the left pane should show the call stack when the crash occurs)? This function doesn't contain anything that could cause a crash.
     
  34. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I've mentioned this a few times. There is a difference between the minimum SDK level (which is what you keep confusing) and the build tools version that is used to generate the actual application. The build tools version has no effect on the minimum SDK level which your app can run on. You need to upgrade it to build NatShare, but it will not prevent you from running NatShare on Android 22 and up.
     
  35. Claude_V

    Claude_V

    Joined:
    Apr 16, 2013
    Posts:
    31
    Some additional information :
    - I restart the scene, therefor I use static variables
    - I mentioned before I suspect "deviceQuery.currentDevice is CameraDevice devicecam" to become false at certain conditions. Not sure how to react when this happens, you will see I re-call Start() when it happens.
    - We test with 5 devices. Over the period of 2 days testing with at least 400 pictures taken, the crash occurred once.
    - It also seems to be related to the app going to and coming back from background, which happens a lot during the testing, and which will happen a lot when it will be live.
    - in the main code I destroy the cameracode.texture before taking a new picture (to avoid memory overflow after many pictures)
    if (cameracode.texture != null) Texture2D.Destroy(cameracode.texture);
    cameracode.texture = null;

    Additional question : I would like to Pause and Unpause the use of the camera, how can this be done ?

    Thanks for the help.
     

    Attached Files:

    Last edited: Apr 22, 2020
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I recommend stopping the camera when the scene is about to change. Also, don't keep static variables because keeping track of which state to keep or reset can lead to issues like this.
    This is impossible by itself. You can look at the source code for `MediaDeviceQuery`. Its `currentDevice` will never change unless `Advance` is called.
    I still recommend cleaning up your code to avoid these issues.
    You don't need to do anything when the app loses focus.
    Yup this is good practice.
    Just stop and start the camera device.
     
    Claude_V likes this.
  37. Claude_V

    Claude_V

    Joined:
    Apr 16, 2013
    Posts:
    31
    Ok, I ripped out all the statics and do not longer reload my scene. I removed my check also... as you can see in the new attached source.
    I have added "StopRunning()" to my Pause() and "StartRunning()" to my Play() function... when you say "stop" and "start" the camera device you mean calling these ???

    I put the version in live testing tomorrow ... keep you posted on the outcome !
     

    Attached Files:

    Last edited: Apr 22, 2020
    Lanre likes this.
  38. cookys

    cookys

    Joined:
    Jan 26, 2017
    Posts:
    9
    Um! I found the reason, but this is also caused by you! The version of NatShare-API-1.2 you gave can be built on Android SDK 22, but changing to il2cpp mode will fail, and the version of NatShare that was given before -The API solves the problem of il2cpp but can only be built on Android SDK 29! Then you say what should I do?
     
  39. musicdeveloper

    musicdeveloper

    Joined:
    Oct 16, 2019
    Posts:
    68
    Thanks - maybe the user was doing something weird with his audio input... Will probably wait until there's another report of it occurring in the app.
     
    Lanre likes this.
  40. Mukaujoka

    Mukaujoka

    Joined:
    Mar 17, 2017
    Posts:
    17
    Hey Lanre, have you already gotten around to investigating this issue?
     
  41. DKasper_3DQR

    DKasper_3DQR

    Joined:
    Dec 20, 2016
    Posts:
    5
    Hello Lanre,

    I started using your asset a few days ago and tried to build your sample MiniCam scene and my app using your asset. It works great on Android! Unfortunately on iOS both projects fail to build in xCode with an EXC_BAD_ACCESS with code 1 at adress 0x0 which points to Bridge.CameraDevices(out var deviceArray, out var deviceCount) (could track it down via the debugging console of xCode) which is used in MediaDeviceQuery. Because of this bug I can't use your camera features on iOS which really is a big problem for me. Did I do something wrong or is this a known/unknown bug in the asset? And the most important: what can I do to overcome this problem?

    EDIT: The iPad I built on had iOS version 12.3.1. I tried to build on an iPhone with version 13.3.1 and it worked there. Maybe that's a hint?
     
    Last edited: Apr 27, 2020
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    What iPhone are you testing on? The 6? There is a bug specific to the device that I've reported to Apple. I'm waiting to hear back from them.
     
  43. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I'm working on it. After some investigation I found that before the very first recording, iOS reports an incorrect sample rate and channel count (channel count in some cases can be zero). When recording starts it corrects itself, but since we rely on these values before recording starts (for creating the recorder) it causes problems.
     
    Mukaujoka likes this.
  44. DKasper_3DQR

    DKasper_3DQR

    Joined:
    Dec 20, 2016
    Posts:
    5
    I tested on an iPad of the 5th generation (iOS 12.3.1) and on the iPhone XS (iOS 13.3.1) so it's not the device with the bug you described. A colleague of mine also tested on an iPad Air with iOS 12.4 which also doesn't work. He tested on an iPad with iOS 13, too, which worked.
     
  45. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Can you share a screenshot of the Xcode window when the crash occurs? I need to see the call stack.
     
  46. DKasper_3DQR

    DKasper_3DQR

    Joined:
    Dec 20, 2016
    Posts:
    5
    Here is the stack trace of your MiniCam sample scene to a certain degree:

    NatDeviceTest was compiled with optimization - stepping may behave oddly; variables may not be available.
    * thread #1, queue = ‘com.apple.main-thread’, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001026faefc UnityFramework`+[NDCameraDevice devices] + 248
    frame #1: 0x00000001026f9e28 UnityFramework`NDCameraDevices + 52
    frame #2: 0x0000000102701ac8 UnityFramework`MediaDeviceQuery_CameraDevices_m60D429C0F13ECBA83AC11934AE132A7FE128F9BE + 88
    frame #3: 0x0000000102701818 UnityFramework`MediaDeviceQuery__ctor_mEB3759CB8C88782A4CA6BB1C45B81BEAFB3D5236 + 260
    frame #4: 0x0000000102706060 UnityFramework`U3CStartU3Ed__7_MoveNext_m13147601794643A397346DDFEA6CEF8132855AB4 + 368
    frame #5: 0x000000010275c510 UnityFramework`AsyncVoidMethodBuilder_Start_TisU3CStartU3Ed__7_tB0A74987C2EA150C764A91DCF688F1CE8A771F70_m1F114FAFA3323E2851B4B13F070B53F00BB2196D_gshared + 128
    frame #6: 0x0000000102705478 UnityFramework`MiniCam_Start_mB16BB70C54A56B353FC38AE6DEEFDDD7717D30CB + 184
    frame #7: 0x0000000102059420 UnityFramework`RuntimeInvoker_TrueVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017(void (*)(), MethodInfo const*, void*, void**) + 20
    frame #8: 0x00000001026e1618 UnityFramework`il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) + 116
    frame #9: 0x00000001023cf2c0 UnityFramework`scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) + 116
    frame #10: 0x00000001023d9d70 UnityFramework`ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) + 116
    frame #11: 0x00000001023e6470 UnityFramework`MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingExceptionPtr*) + 1972
    frame #12: 0x00000001023e66f0 UnityFramework`MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr) + 84
    frame #13: 0x00000001023e5074 UnityFramework`MonoBehaviour::DelayedStartCall(Object*, void*) + 104
    frame #14: 0x0000000102272f08 UnityFramework`DelayedCallManager::Update(int) + 752
    frame #15: 0x0000000102333f18 UnityFramework`ExecutePlayerLoop(NativePlayerLoopSystem*) + 88
    frame #16: 0x0000000102333f4c UnityFramework`ExecutePlayerLoop(NativePlayerLoopSystem*) + 140
    frame #17: 0x00000001023341a4 UnityFramework`PlayerLoop() + 348
    frame #18: 0x0000000102504450 UnityFramework`UnityPlayerLoopImpl(bool) + 240
    frame #19: 0x000000010201bc04 UnityFramework`UnityRepaint + 140
    frame #20: 0x000000010201bae0 UnityFramework`-[UnityAppController(Rendering) repaintDisplayLink] + 88
    frame #21: 0x00000001cabeff90 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 636
    frame #22: 0x00000001c6ac44b0 IOKit`IODispatchCalloutFromCFMessage + 488
    frame #23: 0x00000001c67d3a8c CoreFoundation`__CFMachPortPerform + 188
    frame #24: 0x00000001c67fa690 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
    frame #25: 0x00000001c67f9ddc CoreFoundation`__CFRunLoopDoSource1 + 440
    frame #26: 0x00000001c67f4c00 CoreFoundation`__CFRunLoopRun + 2096
    frame #27: 0x00000001c67f40b0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #28: 0x00000001c89f479c GraphicsServices`GSEventRunModal + 104
    frame #29: 0x00000001f2d9e978 UIKitCore`UIApplicationMain + 212
    frame #30: 0x000000010201a5a4 UnityFramework`-[UnityFramework runUIApplicationMainWithArgc:argv:] + 108
    * frame #31: 0x000000010061be1c NatDeviceTest`main(argc=<unavailable>, argv=<unavailable>) at main.mm:26:9 [opt]
    frame #32: 0x00000001c62b98e0 libdyld.dylib`start + 4
    thread #2
    frame #0: 0x00000001c6405b74 libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001c6488138 libsystem_pthread.dylib`_pthread_wqthread + 340
    frame #2: 0x00000001c648acd4 libsystem_pthread.dylib`start_wqthread + 4
    thread #3
    frame #0: 0x00000001c6405b74 libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001c6488138 libsystem_pthread.dylib`_pthread_wqthread + 340
    frame #2: 0x00000001c648acd4 libsystem_pthread.dylib`start_wqthread + 4
    thread #4, name = ‘com.apple.uikit.eventfetch-thread’
    frame #0: 0x00000001c63fa0f4 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x00000001c63f95a0 libsystem_kernel.dylib`mach_msg + 72
    frame #2: 0x00000001c67f9a10 CoreFoundation`__CFRunLoopServiceMachPort + 236
    frame #3: 0x00000001c67f4920 CoreFoundation`__CFRunLoopRun + 1360
    frame #4: 0x00000001c67f40b0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #5: 0x00000001c71c1fac Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
    frame #6: 0x00000001c71c1e3c Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 96
    frame #7: 0x00000001f2e84494 UIKitCore`-[UIEventFetcher threadMain] + 136
    frame #8: 0x00000001c72ee6a4 Foundation`__NSThread__start__ + 984
    frame #9: 0x00000001c64872c0 libsystem_pthread.dylib`_pthread_body + 128
    frame #10: 0x00000001c6487220 libsystem_pthread.dylib`_pthread_start + 44
    frame #11: 0x00000001c648acdc libsystem_pthread.dylib`thread_start + 4
    thread #5
    frame #0: 0x00000001c648acd0 libsystem_pthread.dylib`start_wqthread
    thread #6
    frame #0: 0x00000001c648acd0 libsystem_pthread.dylib`start_wqthread
    thread #7
    frame #0: 0x00000001c6405b74 libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001c6488138 libsystem_pthread.dylib`_pthread_wqthread + 340
    frame #2: 0x00000001c648acd4 libsystem_pthread.dylib`start_wqthread + 4
    thread #8, name = ‘GC Finalizer’
    frame #0: 0x00000001c6404ee4 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x00000001c647fcf8 libsystem_pthread.dylib`_pthread_cond_wait$VARIANT$mp + 636
    frame #2: 0x00000001026bc41c UnityFramework`il2cpp::eek:s::posix::posixWaitObject::Wait(unsigned int, bool) + 400
    frame #3: 0x000000010269d8a8 UnityFramework`il2cpp::gc::FinalizerThread(void*) + 104
    frame #4: 0x00000001026b6e50 UnityFramework`il2cpp::eek:s::Thread::RunWrapper(void*) + 88
    frame #5: 0x00000001026b897c UnityFramework`il2cpp::eek:s::ThreadImpl::ThreadStartWrapper(void*) + 40
    frame #6: 0x00000001c64872c0 libsystem_pthread.dylib`_pthread_body + 128
    frame #7: 0x00000001c6487220 libsystem_pthread.dylib`_pthread_start + 44
    frame #8: 0x00000001c648acdc libsystem_pthread.dylib`thread_start + 4
    thread #9, name = ‘Job.Worker 0’
    frame #0: 0x00000001c63fa130 libsystem_kernel.dylib`semaphore_wait_trap + 8
    frame #1: 0x00000001c624a798 libdispatch.dylib`_dispatch_sema4_wait$VARIANT$mp + 24
    frame #2: 0x00000001c624b21c libdispatch.dylib`_dispatch_semaphore_wait_slow + 140
    frame #3: 0x000000010256b404 UnityFramework`Baselib_SystemSemaphore_Acquire + 28
    frame #4: 0x00000001022c8d88 UnityFramework`CappedSemaphore::WaitForSignalInternal(bool) + 132
    frame #5: 0x000000010230810c UnityFramework`JobQueue::processJobs(JobQueue::ThreadInfo*, void*) + 236
    frame #6: 0x000000010230767c UnityFramework`JobQueue::WorkLoop(void*) + 56
    frame #7: 0x000000010239b660 UnityFramework`Thread::RunThreadWrapper(void*) + 76

    Or do you really need a screenshot which shows something else?
     
  47. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    109
    Hi,

    I just purchased NatDevice and I can't seem to be able to capture the camera output with NatCorder.
    Also I couldn't find anything in the documentation.

    Please help.
     
  48. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    109
    One more thing that I am experiencing is that I cannot switch to front facing camera on my Android phone and the display is getting skewed when I rotate the phone..

    Thanks for your help.
     
  49. Shane-Pangea

    Shane-Pangea

    Joined:
    Dec 12, 2012
    Posts:
    38
    @Lanre
    With NatDevice, for Windows desktop as the platform; I am able to retrieve the list of available cameras, but is there a way that I can set which camera is to be used? There may be multiple webcams attached to the computer. So the user can choose which camera to use. The only method I found to switch cameras is deviceQuery.Advance(). Anything like deviceQuery.UseCamera("uniqueID") ?

    Thanks! :)
     
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I need to see the full thing, so share the full logs with all threads and a screenshot of Xcode.