How can I track down interference between the flutter libraries audo_recorder and stereo - flutter

I'm building an app with Flutter that allows me to record audio and then play it back later. I'm using the package audio_recorder 0.4.0 for recording the audio and the package stereo 1.0.0 for playing back the audio.
When I record using the iOS simulator, everything works fine. But when I run on the physical device (iPhone 6 Plus), I always get a 28 byte file at the end of the recording session - basically just a header to the m4a file.
I've tracked this down to some kind of interference between the two libraries. I can record on the physical device just fine if I use the sample app included with audio_recorder 0.4.0. But all I have to do is add the line stereo: 1.0.0 to the dependencies in pubspec.yml of that same sample project and suddenly I start getting the 28 byte files on the physical device at the end of a recording session instead of a normal size m4a file.
I have a two-part question:
What kind of interference could the stereo library be causing to make this kind of failure in the audio_recorder library? I suspected channel interference, but my attempt to isolate that didn't yield anything.
How can I track down what is causing this?
I have examined the console output from both sessions. When it is failing, I see several (8) of these lines in the the console output right after attempting to start recording:
mediaserverd 1111: AudioConverterNew returned -50
Others have suggested that this error occurs when there is no microphone available.
I also see this suspicious difference between the outputs.
When recording is broken:
default 11:36:57.098825 -0700 mediaserverd 4414: { "action":"set_play_state", "session":{"ID":"0x3315820","PID":14591,"name":"Runner"}, "details":"entry" }
default 11:36:57.100484 -0700 mediaserverd -CMSessionMgr- cmsSetIsPlaying: CMSession: 'sid:0x3315820, Runner(14591), 'prim'' with [MediaPlayback/Default] [NonMixable] [System Audio] starting playing.
default 11:36:57.104699 -0700 mediaserverd CAReportingClient.mm:328:-[CAReportingClient sendMessage:category:type:reporters:]: message {
Volume = "0.75";
VolumeCategory = "Audio/Video";
VolumeOperationProcess = "com.monkela.audioRecordSample";
VolumeOperationTime = 576708;
VolumePlayingState = 1;
}: (
857014545
)
default 11:36:57.105879 -0700 mediaserverd -CMVAEndptMgr- vaemSetDeviceVolume: CMSession: Setting cmsvolume = 0.750 for device ID: VirtualAudioDevice_Default
default 11:36:57.107295 -0700 mediaserverd VirtualAudio_Device.cpp:2046:SetPropertyData: [volm/outp/0] on device [ type: vdef; id: 354; addr: 0x1014e1ba0; hidden: 0; VA strms: { o/883/0x106fc5980 }; agg dev: [ id: 872; addr: 0x106f1a460; uid: "VAD [vdef] AggDev 52"; virt strms: { }; phys devs: { [ id: 292; addr: 0x104b0fdb0; uid: "Speaker"; streams: { i/294/0x104b11cd0, o/293/0x104b12790 } ] } ] ]: 0.750000.
default 11:36:57.108123 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:662:CommitVolume: Setting Volume = -14.500000 dB, Final HW Volume = 0.000000 dB, Final SW Volume = -14.500000 dB, External Volume Handler: No
default 11:36:57.109008 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:663:CommitVolume: PhysicalDevice UID = "Speaker"
default 11:36:57.109721 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:664:CommitVolume: Scope = 1869968496 ("outp")
default 11:36:57.110704 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:665:CommitVolume: Element = 0 ("0")
default 11:36:57.112062 -0700 mediaserverd OutputVolumeControl_HAL_Common.cpp:698:CommitVolume: SW Volume: 0.750000 scalar
default 11:36:57.114393 -0700 mediaserverd VirtualAudio_Device.cpp:2066:SetPropertyData: Client request to set nominal sample rate to 44100.000000 on VAD 354.
default 11:36:57.116038 -0700 assertiond [Runner:14591] Attempting to acquire assertion for Runner:14591: <BKProcessAssertion: 0x101349110; "CMSession.14591."com.monkela.audioRecordSample"."MediaPlayback".isPlayingProcessAssertion" (audio:inf); id:…C74721DE1F95>
default 11:36:57.116572 -0700 assertiond [Runner:14591] Add assertion: <BKProcessAssertion: 0x101349110; id: 13077-914DDDE2-35CE-4420-85ED-C74721DE1F95; name: CMSession.14591."com.monkela.audioRecordSample"."MediaPlayback".isPlayingProcessAssertion; state: active; reason: audio; duration: infs> {
owner = <BSProcessHandle: 0x101009be0; mediaserverd:13077; valid: YES>;
flags = preventSuspend, preventThrottleDownCPU, preventIdleSleep, preventSuspendOnSleep;
}
When recording is working:
default 11:39:19.865022 -0700 mediaserverd 2863: { "action":"activate", "session":{"ID":"0x3315826","PID":14609,"name":"Runner"}, "details":"entry" }
default 11:39:19.880637 -0700 mediaserverd CAReportingClient.mm:328:-[CAReportingClient sendMessage:category:type:reporters:]: message {
"active devices" = "[ { vdef, [ ], [ pspk ( 0 ) ] }, { vspd, [ pmbi ( 0 ) ], [ ] }, { vcal, [ pdln ( 0 ) ], [ puln ( 0 ) ] } ]";
category = csav;
"going_active" = 1;
mode = imdf;
"staying_active" = 0;
}: (
857014546
)
The output when recording is broken suggests that my attempt to start recording actually starts playing something (i.e. invoking the wrong library).

I tracked this down and figured out how to make the libraries work together by modifying the stereo package. It turns out the stereo package was activating a playback audio session in application didFinishLaunchingWithOptions. Essentially these lines:
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:&error];
[session setActive:YES error:&error];
I forked the stereo package and changed the code to activate the playback session only when it is actually needed. Magically my record function started working.
I'm not sure why it ever worked in the simulator. Somehow the simulator must be able to have both a playback and recording session going simultaneously.
UPDATE: The author of the stereo package accepted my pull request so as long as you have version 1.0.1 of the package, you should be able to avoid this interference issue.

Related

WeatherKit⛈ iOS SDK 401 network error WWDC 2022

I am getting an error while running WWDC22 Link
I downloaded the sample Project from Apple from here
And I am able to run the project. But when I create a Demo project and added Weather fetching code getting I am getting Error.
My Code:
func fetchWeather() async {
let service = WeatherService.shared
var location: CLLocation = CLLocation(latitude: 22.7196, longitude: 75.8577)
let weatherData = try? await service.weather(for: location, including: .current)
print(weatherData)
}
Error:
2022-06-22 17:31:48.470130+0530 WeatherAPIDemo[25490:231389] [Database] Attempting to invalidate an assertion that is no longer valid 2022-06-22 17:31:49.208346+0530 WeatherAPIDemo[25490:231387] [WeatherService] Encountered an error when fetching weather data subset; location= +/- 0.00m (speed -1.00 mps / course -1.00) # 6/22/22, 5:31:48 PM India Standard Time, error=invalidJWTResponse(Optional( { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {
Connection = (
close
);
"Content-Length" = (
0
);
Date = (
"Wed, 22 Jun 2022 12:01:49 GMT"
);
Server = (
Apple
);
"Strict-Transport-Security" = (
"max-age=31536000; includeSubdomains"
);
"X-Apple-Origin" = (
"8961098f-b238-3714-ba44-5b569c861456"
);
"X-Cache" = (
"TCP_MISS from a49-44-192-207.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)"
);
"X-Content-Type-Options" = (
nosniff
);
"X-Frame-Options" = (
SAMEORIGIN
);
"X-REQUEST-ID" = (
"8c733cde-5aa3-499c-b555-05c5aab5e278"
);
"X-XSS-Protection" = (
"1; mode=block"
);
} }))
nil
Apple Developer Program membership is required.
From: https://developer.apple.com/weatherkit/get-started/
Requirements
Apple Developer Program membership
Access to WeatherKit beta is included in the Apple Developer Program,
which also provides all the tools, resources, and support you need to
develop and distribute apps — including access to beta software, app
services, testing tools, app analytics, and more.
I tried a lot even I have added WeatherKit in Capabilities But didn't worked.
I thought the issue must be that I don’t have the Developer Account But then I realised that the Apple Demo Project is also working even without adding any Team (see below img for Apple Demo Project).
Then I just copy and pasted the same Bundle Identifier in my Demo project and Boom! it worked like Hell.

Use GPIO as chip select for SPI ACPI overlay

I want to use a GPIO pin as a new chip select for SPI on an Up Squared board. The Up squared uses an Intel Pentium N4200, so it's a x86 machine. I have managed to this on a Raspberry Pi by using Device Tree Overlays but as this is an x86 machine I may have to use ACPI overlays.
The Up squared has two spi available and they propose here to use ACPI overlays, this repo, which actually works very well. Below one of the asl files they use
/*
* This ASL can be used to declare a spidev device on SPI0 CS0
*/
DefinitionBlock ("", "SSDT", 5, "INTEL", "SPIDEV0", 1)
{
External (_SB_.PCI0.SPI1, DeviceObj)
Scope (\_SB.PCI0.SPI1)
{
Device (TP0) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI test device connected to CS0")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
0, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 10 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI1", // SPI host controller
0 // Must be 0
)
})
}
}
}
I compiled this file using
$ sudo iasl spidev1.0.asl > /dev/null
$ sudo mv spidev1.0.asl /lib/firmware/acpi-upgrades
$ sudo update-initramfs -u -k all
Then I reboot an I can see a device and communicate through it.
up#up:~$ ls /dev/spi*
/dev/spidev1.0
Thus, I decided to write my own overlay based on themeta-acpi samples from intel and I wrote this:
/*
* This ASL can be used to declare a spidev device on SPI0 CS2
*/
DefinitionBlock ("", "SSDT", 5, "INTEL", "SPIDEV2", 1)
{
External (_SB_.PCI0.SPI1, DeviceObj)
External (_SB_.PCI0.GIP0.GPO, DeviceObj)
Scope (\_SB.PCI0.SPI1)
{
Name (_CRS, ResourceTemplate () {
GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionOutputOnly,
"\\_SB.PCI0.GIP0.GPO", 0) {
22 // pin 22 is BCM25 or 402 in linux
}
})
Name (_DSD, Package() {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () { "compatible", "spidev" }, // not sure if this is needed
Package () {
"cs-gpios", Package () {
0,
0,
^SPI1, 0, 0, 0, // index 0 in _CRS -> pin 22
}
},
}
})
Device (TP2) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI test device connected to CS2")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
2, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 10 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI1", // SPI host controller
0 // Must be 0
)
})
}
}
}
But I cannot see the new device. What am I missing?
Edit:
I have modified the code with a code which actually worked. I can see now a device on /dev/spidev1.2.
However, the CS on pin 22 is low all the time which shouldn't be the case. is the number of the pin correct? I'm using pin numbering from here
Edit 2:
Here is the output of my kernel version
Linux up 5.4.65-rt38+ #1 SMP PREEMPT_RT Mon Feb 28 13:42:31 CET 2022 x86_64 x86_64 x86_64 GNU/Linux
I compiled this up linux repository with the RT patch for the right kernel version.
I also installed the upboard-extras package and I'm actually able to communicate through spi for devices /dev/spidev1.0 and /dev/spidev1.1. So I think I have configured the up squared correctly.
There is nongpio file under /sys/class/gpio
up#up:~/aru$ ls /sys/class/gpio
export gpiochip0 gpiochip267 gpiochip310 gpiochip357 gpiochip434 unexport
I can set the GPIO to 1 or 0 and I can see the output on a multimeter, so I think I have right permissions for GPIO.
Edit 3:
Please find in this link the .dat result from acpidump -o up2-tables.dat
I assume that you are using this board. To be able to use I/O pins(i2c, spi etc.), you need to enable them firstly. Easy way to check you already enabled them or not is that typing in terminal:
uname -a
Output of this will be look like:
Linux upxtreme-UP-WHL01 5.4.0-1-generic #2~upboard2-Ubuntu SMP Thu Jul 25 13:35:27 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
In here #2~upboard2-Ubuntu part can be changed accordingto your board type. However if you don't see a similar result, then you didn't configure your board yet. Otherway to check it, go to folder: /sys/class/gpio and check the ngpio file. Inside it, there should be written 28.
To use any I/O pins(i2c, spi etc.), you don't need to change anything on BIOS side, because its coming to you defaultly enabled.
Please check the up-wiki page, and update your board kernel after linux installation. Then your I/O configurations will be enabled. Up-wiki main page.

VxWorks 653 Restart after START command

Using VxWorks 653 2.5.0.2 for P2020RDB-PC target, using BSP1.0/4
I have a very simple test application
void usrAppInit (void)
{
RETURN_CODE_TYPE errCode;
printf("\n I am alive!");
PROCESS_ATTRIBUTE_TYPE processAttributes;
PROCESS_ID_TYPE thandle;
processAttributes.BASE_PRIORITY = 10;
processAttributes.DEADLINE = SOFT;
processAttributes.ENTRY_POINT = (SYSTEM_ADDRESS_TYPE)task;
strncpy(processAttributes.NAME, "TASK", MAX_NAME_LENGTH);
processAttributes.PERIOD = INFINITE_TIME_VALUE;
processAttributes.STACK_SIZE = 1024;
processAttributes.TIME_CAPACITY = INFINITE_TIME_VALUE;
CREATE_PROCESS(&processAttributes, &thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error creating the task: %d", errCode);
}
else
{
START(thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error starting the task: %d", errCode);
}
}
SET_PARTITION_MODE (NORMAL, &errCode);
if (errCode != NO_ERROR){
printf("\nError changing partition mode: %d", errCode);
}
while(1);
}
void task()
{
printf("\nI am a process.");
while(1);
}
When the program gets to the START line, it reboots. If I comment out the START line, it executes till the end of the main and obviously does nothing. I have tried to increase partition memory and I am adding the APEX components to the makefile.
What could be causing this?
PS: system output
VxWorks 653 System Boot
Copyright (c) 1984-2016 Wind River Systems, Inc.
CPU: Freescale P2020E - Security Engine
Version: 2.5.0.2
BSP version: 1.0/4
Creation date: Apr 29 2020, 15:00:10
Press any key to stop auto-boot...
0
auto-booting...
boot device : mottsec
unit number : 0
processor number : 0
host name : felipe
file name : D:\Projects\WindRiver\helloWorld\boot.txt
inet on ethernet (e) : 192.168.1.172
host inet (h) : 192.168.1.75
gateway inet (g) : 192.168.1.1
user (u) : felipe
ftp password (pw) : pass
flags (f) : 0x0
target name (tn) : board
Attached TCP/IP interface to mottsec0.
Warning: netmask value is 0.
Attaching interface lo0...done
Loading D:\Projects\WindRiver\helloWorld\boot.txt
sm0=D:\Projects\WindRiver\helloWorld\configRecord.reloc
0x00001a00 + (0x000fe600)
sm1=D:\Projects\WindRiver\helloWorld\coreOS.sm
0x00050e08 + 0x00007130 + 0x00006084 + 0x00015cac
sm2=D:\Projects\WindRiver\helloWorld\vxSysLib.sm
0x00031078 + 0x00004b20 + 0x00000918 + 0x00001d90
sm3=D:\Projects\WindRiver\helloWorld\fsl_p2020_rdb_part1.sm
0x000027c8 + 0x000000d0 + 0x00000010 + 0x00000008
Starting at 0x100000...
After this, it returns to the beggining and repeats the process forever
So, in case anyone else drops here with similar issue, in my case there were two main things affecting the functionality.
First, in the usrAppInit() function, one cannot define the while(1) loop in the end of the function. On opposite to other ARINC-653 systems, where the partition main is the same as the user main, for VxWorks it does not seems to be the case. This way, after SET_PARTITION_MODE, nothing else can be defined.
Second, the stack size for the process was too small. That fit perfectly for different targets and ARINC RTOS (in-house OS, executing on ARMv7 target), but for VxWorks on the P2020 target it requires a bigger stack. In this case, I've used 4096.
Here is the complete example code, now functional, in case anyone needs this.
void usrAppInit (void)
{
RETURN_CODE_TYPE errCode;
printf("\n I am alive!");
PROCESS_ATTRIBUTE_TYPE processAttributes;
PROCESS_ID_TYPE thandle;
processAttributes.BASE_PRIORITY = 10;
processAttributes.DEADLINE = SOFT;
processAttributes.ENTRY_POINT = (SYSTEM_ADDRESS_TYPE)task;
strncpy(processAttributes.NAME, "TASK", MAX_NAME_LENGTH);
processAttributes.PERIOD = INFINITE_TIME_VALUE;
processAttributes.STACK_SIZE = 4096;
processAttributes.TIME_CAPACITY = INFINITE_TIME_VALUE;
CREATE_PROCESS(&processAttributes, &thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error creating the task: %d", errCode);
}
else
{
START(thandle, &errCode);
if(errCode != NO_ERROR)
{
printf("Just had an error starting the task: %d", errCode);
}
}
SET_PARTITION_MODE (NORMAL, &errCode);
if (errCode != NO_ERROR){
printf("\nError changing partition mode: %d", errCode);
}
}
void task()
{
printf("\nI am a process.");
while(1);
}

Camera bar code scan crash with iPhone 11 and iOS 13

We have code in a Xamarin App using bar code scanning. It has been working successfully for 3 years. We have found an issue with the iPhone 11 pro and its three camera setup.
_captureSession = new AVCaptureSession();
CameraMetaDataDelegate del = null;
AVCaptureDevice captureDevice =
AVCaptureDevice.GetDefaultDevice(AVMediaType.Video);
if (captureDevice != null)
{
var videoInput = AVCaptureDeviceInput.FromDevice(captureDevice, out error);
if (videoInput != null) { _captureSession.AddInput(videoInput); }
else { iApp.Log.Error("Video capture error: " + error.LocalizedDescription); }
var metaDataOutput = new AVCaptureMetadataOutput();
_captureSession.AddOutput(metaDataOutput);
del = new CameraMetaDataDelegate(this, _layer);
metaDataOutput.SetDelegate(del, CoreFoundation.DispatchQueue.MainQueue);
metaDataOutput.MetadataObjectTypes = metaDataOutput.AvailableMetadataObjectTypes;
_videoPreviewLayer = new AVCaptureVideoPreviewLayer(_captureSession) {
Frame = View.Bounds,
Orientation = (AVCaptureVideoOrientation)InterfaceOrientation,
};
View.Layer.AddSublayer(_videoPreviewLayer);
...
We have the the necessary entitlements in the info.plist
<key>NSCameraUsageDescription</key>
<string>Scan Barcodes</string>
It seems to be crashing on the AVCaptureDeviceInput. The "Application would like access to the camera" popup remains on the screen after the crash.
This works on older iPhones. We have not tried on an iPhone 11 non-pro.
Log looks like this
default 17:46:52.725211 -0500 tccd PID[30] is checking access for target PID[933]
default 17:46:52.734801 -0500 mediaserverd Updating configuration of monitor <RBSProcessMonitorConfiguration: 0x10cc25430; id: M30-27; qos: 25> {
predicates = {
<RBSProcessPredicate: 0x103735f30> {
predicate = <RBSCompoundPredicate; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x103104870>>; <RBSProcessBundleIdentifierPredicate; com.apple.InCallService>>;
};
}
descriptor = <RBSProcessStateDescriptor: 0x10cc46300; values: 11> {
namespaces = {
com.apple.frontboard.visibility;
}
};
}
default 17:46:52.735816 -0500 mediaserverd BKSApplicationStateMonitor updated with invalid process
default 17:46:52.736059 -0500 runningboardd [daemon<com.apple.mediaserverd>:30] handle lookup could not find a matching process
default 17:46:52.736188 -0500 mediaserverd <<<< FigCaptureClientSessionMonitor >>>> -[FigCaptureClientSessionMonitor _updateClientStateCondition:newValue:]: <private> Updating client with application state "Foregrounded" and layout state "None"
default 17:46:52.736343 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_updateRunningCondition: <0x102eddb90> (PID:933): ClientStartedSession:0 Cam/Audio:0/0 bg:0 prewarming:0 int:0 windowed:0 devStolen:0, pressured:0, active:0 shouldRun:0, start:0 stop:0 stopRecordingIfActive:0
default 17:46:52.746798 -0500 mediaserverd Creating remote service object
default 17:46:52.748227 -0500 applecamerad <private>
default 17:46:52.748255 -0500 applecamerad <private>
default 17:46:52.748282 -0500 applecamerad <private>
default 17:46:52.748314 -0500 applecamerad <private>
default 17:46:52.748348 -0500 applecamerad H10ISPFlickerDetectorCreate - HWType = 3; pContext = 0x104c0e830
default 17:46:52.748377 -0500 applecamerad FlickerDetector: ArbiterClient resource access granted=1
default 17:46:52.749880 -0500 mediaserverd 2325: [volm/inpt/0] on device [ type: vhaw; id: 233; addr: 0x109a33d60; hidden: 0; VA strms: { i/238/0x109a34bc0, }; agg dev: [ id: 203; addr: 0x10c38d800; uid: "VAD [vhaw] AggDev 6"; virt strms: { }; phys devs: { [ id: 94; addr: 0x102e1af80; uid: "Hawking"; streams: { i/95/0x102e1b2d0, } ] } ] ]: 1.000000.
default 17:46:52.749914 -0500 mediaserverd 161: Setting Input Volume: 18.000000 dB, Final HW Volume: 18.000000 dB, Final SW Volume: 0.000000 dB
default 17:46:52.749945 -0500 mediaserverd 162: PhysicalDevice UID = "Hawking"
default 17:46:52.750012 -0500 mediaserverd 163: Scope = 1768845428 ("inpt")
default 17:46:52.750041 -0500 mediaserverd 164: Element = 0 ("0")
default 17:46:52.750405 -0500 applecamerad AURemoteIO.cpp:1546:Start: Starting AURemoteIO(0x107008c40)
output client: 1 ch, 0 Hz, Float32, output HW: 1 ch, 0 Hz, Float32
input client: 2 ch, 16000 Hz, Float32, inter, input HW: 2 ch, 16000 Hz, Float32, non-inter
default 17:46:52.750485 -0500 applecamerad AURemoteIO.cpp:1556:Start: work interval port 0x607b
default 17:46:52.751151 -0500 mediaserverd MEDeviceStreamClient.cpp:216:AddRunningClient: AQME device VirtualAudioDevice_Hawking: client starting: <RemoteIOClient#0x10500e600(#0x10500e658); input; CMSession(applecamerad[116])>; running count now 1
default 17:46:52.751186 -0500 mediaserverd 671: Client request to start IO proc ID 0x109a4abc0 on VAD 233.
default 17:46:52.751276 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_SetConfiguration: <0x102eddb90> (PID:933): New configuration: <private>
default 17:46:52.751375 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_updateRunningCondition: <0x102eddb90> (PID:933): ClientStartedSession:0 Cam/Audio:0/0 bg:0 prewarming:0 int:0 windowed:0 devStolen:0, pressured:0, active:0 shouldRun:0, start:0 stop:0 stopRecordingIfActive:0
default 17:46:52.751608 -0500 mediaserverd 599: Starting IO type 0 on AggregateDevice 203.
default 17:46:52.751655 -0500 mediaserverd HALS_IOContext::StartIOProcID: 206 Hawking (VAD [vhaw] AggDev 6):
default 17:46:52.753329 -0500 mediaserverd starting ProcID 0x21 state: Prewarm: 0 Play: 0 State: Stopped IOProc 0x21: no
default 17:46:52.753407 -0500 mediaserverd HALS_Device::_GetCombinedVolumeScalar: client 0 is not present and has a combined volume scalar is 1.000000
default 17:46:52.753633 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_SetConfiguration: <0x102eddb90> (PID:933): New configuration: <private>
default 17:46:52.753700 -0500 CommCenter #I <private> request: <private>.
default 17:46:52.753812 -0500 mediaserverd <<<< FigCaptureSession >>>> captureSession_updateRunningCondition: <0x102eddb90> (PID:933): ClientStartedSession:0 Cam/Audio:1/0 bg:0 prewarming:0 int:0 windowed:0 devStolen:0, pressured:0, active:0 shouldRun:0, start:0 stop:0 stopRecordingIfActive:0
default 17:46:52.753934 -0500 CommCenter #I Received Audio State: <private>
default 17:46:52.753974 -0500 nfcd 00000001 57f02250 -[NFCameraStateMonitor _updateCameraStateValue:]:203 current=0, new=5
default 17:46:52.754014 -0500 mediaserverd 65: :413:: IOProc (AggregateDevice 203, IO type NonNullIOProc) running state is now running (2).
default 17:46:52.754047 -0500 nfcd 00000001 57f02250 -[NFCameraStateMonitor _updateCameraStateValue:]:203 current=5, new=7
default 17:46:52.754078 -0500 nfcd 00000001 57f02250 -[NFCameraStateMonitor _updateCameraStateValue:]:203 current=7, new=15
default 17:46:52.754405 -0500 backboardd Connection removed: IOHIDEventSystemConnection uuid:07F3B331-86A0-445F-ABA7-DDDA546740A7 pid:933 process:MYAPP5 type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 384 attributes:{
HighFrequency = 1;
bundleID = "com.MYCOMPANY.mobile.MYAPP.development";
pid = 933;
} inactive:0 events:102 mask:0x800
default 17:46:52.754543 -0500 backboardd HIDAnalytics Unregister Send event com.apple.hid.queueUsage
default 17:46:52.755359 -0500 SpringBoard Workspace connection invalidated for <FBWorkspaceServer: 0x2822ce040>
default 17:46:52.755514 -0500 SpringBoard [application<com.MYCOMPANY.mobile.MYAPP.development>:933] Now flagged as pending exit for reason: workspace client connection invalidated
default 17:46:52.755776 -0500 SpringBoard Updating configuration of monitor <RBSProcessMonitorConfiguration: 0x2823ed600; id: M57-6; qos: 25> {
predicates = {
<RBSProcessPredicate: 0x283a521b0> {
predicate = <RBSCompoundPredicate; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x283a40340>>; <RBSProcessBundleIdentifierPredicate; com.apple.springboard>>;
};
<RBSProcessPredicate: 0x283a5c2e0> {
predicate = <RBSCompoundPredicate; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x283a40340>>; <RBSProcessBundleIdentifierPredicate; com.apple.MailCompositionService>>;
};
<RBSProcessPredicate: 0x283a5c2d0> {
predicate = <RBSCompoundPredicate; <RBSProcessBundleIdentifierPredicate; com.apple.ScreenshotServicesService>; <RBSCompoundPredicate; <RBSProcessEUIDPredicate; 501>; <RBSProcessBKSLegacyPredicate: 0x283a40340>>>;
};
<RBSProcessPredicate: 0x283a5d2e0> {
predicate = <RBSCompoundPredicate; <RBSCompou<…>
default 17:46:52.755823 -0500 SpringBoard connection invalidated
default 17:46:52.755869 -0500 SpringBoard connection invalidated
default 17:46:52.756102 -0500 CommCenter Client [<private>] disconnected (conn=0x101590a20), client list size 35
default 17:46:52.756159 -0500 locationd #Spi, Connection invalidated for process <private>
Not sure if it is another permissions issue, or using the wrong AV API, or need another preliminary step. Perhaps a race condition that should delay until camera responds available?
Junior Jiang's suggestion led me down the path to getting the iPhone 11 pro bar code scanning. First it really is necessary to check the authorization status, which used to fire on the first request before. Once this is established, then the camera will work. The second problem is that, at least in Xamarin C#, I could not assign the list of AvailableMetaDataObjectTypes. There is an earlier Stack Overflow which directs to use that list: Stack Overflow Xcode 9/Swift 4 AVCaptureMetadataOutput setMetadataObjectTypes use availableMetadataObjectTypes
But now the solution was to explicitly state which ones to use.
_captureSession = new AVCaptureSession();
CameraMetaDataDelegate del = null;
var authStatus = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);
AVCaptureDevice captureDevice = null;
// check authorization status
if (authStatus == AVAuthorizationStatus.Authorized)
{
captureDevice = AVCaptureDevice.GetDefaultDevice(AVMediaType.Video); // update for iOS 13
}
else if (authStatus == AVAuthorizationStatus.NotDetermined)
{
AVCaptureDevice.RequestAccessForMediaType(AVMediaType.Video, (granted) =>
{
if (!granted)
{
Log.Error("ViewDidLoadBase ScanLayer RequestAccessForMediaType not granted!");
}
else
{
Log.Error("ViewDidLoadBase ScanLayer RequestAccessForMediaType granted!");
}
});
}
else
{
Log.Error("Not Authorized! Status: " + authStatus.ToString());
}
if (captureDevice != null)
{
var videoInput = AVCaptureDeviceInput.FromDevice(captureDevice, out error);
if (videoInput != null)
{
_captureSession.AddInput(videoInput);
}
else
{
Log.Error("Video capture error: " + error.LocalizedDescription);
}
var metaDataOutput = new AVCaptureMetadataOutput();
_captureSession.AddOutput(metaDataOutput);
del = new CameraMetaDataDelegate(this, _layer);
metaDataOutput.SetDelegate(del, CoreFoundation.DispatchQueue.MainQueue);
//metaDataOutput.MetadataObjectTypes = metaDataOutput.AvailableMetadataObjectTypes;
metaDataOutput.MetadataObjectTypes = AVMetadataObjectType.QRCode | AVMetadataObjectType.Code128Code | AVMetadataObjectType.UPCECode | AVMetadataObjectType.EAN13Code ;
_videoPreviewLayer = new AVCaptureVideoPreviewLayer(_captureSession) {
Frame = View.Bounds,
Orientation = (AVCaptureVideoOrientation)InterfaceOrientation,
};
View.Layer.AddSublayer(_videoPreviewLayer);

Core data migration - Appstore build crashing on iOS 8 devices, working on iOS 9

My app store update build is crashing, it's a core data crash but I am getting this crash on only iOS 8 devices, it is working fine on iOS 9 devices.
I have correctly performed light weight migration as well added the new model version keeping the old one as a base, added the dictionary in options as well while adding "addPersistentStoreWithType".
ManagedObjectModel
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
let modelURL = NSBundle.mainBundle().URLForResource("abcProject", withExtension: "momd")
NSLog("Url is - \(modelURL)")
return NSManagedObjectModel(contentsOfURL: modelURL!)!
}()
PersistentStoreCoordinator
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject")
var error: NSError? = nil
var failureReason = "There was an error creating or loading the application's saved data."
do {
let mOptions = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]
NSLog("TEST564 - 7 URL - \(url)")
try coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: mOptions)
} catch var error1 as NSError {
error = error1
coordinator = nil
// Report any error we got.
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("TEST564 Unresolved error \(error), \(error!.userInfo)")
abort()
} catch {
fatalError()
NSLog("TEST564 FATAL error")
}
return coordinator
}()
Above is my set of code for reference. I have searched everywhere and I get details about the light weight migration only.
Following is the device log after crash:-
> Jul 19 11:25:00 iPhone abcProject-Production[211] <Warning>: CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null)
URL:file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)"
UserInfo=0x16b05490 {URL=file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject, metadata={
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
TabBanner = <3722cf8b 4ac58f43 20c84d7e 7d66865d a1382ecc 1ab25190 7b7c3fa7 843813fe>;
Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>;
};NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "79788D63-BEF2-4339-BF60-1580904D9B44";
"_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store} with userInfo dictionary {
URL = "file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject";
metadata = {
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
TabBanner = <3722cf8b 4ac58f43 20c84d7e 7d66865d a1382ecc 1ab25190 7b7c3fa7 843813fe>;
Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "79788D63-BEF2-4339-BF60-1580904D9B44";
"_NSAutoVacuumLevel" = 2;
};
reason = "Can't find model for source store";
}
Jul 19 11:25:00 iPhone abcProject-Production[211] <Warning>: CoreData: annotation: NSPersistentStoreCoordinator's current model hashes are {
TabBanner = <2efd2387 6f370f71 d585132f 9d6aa8fe afcdc841 ef6e9b89 396625d1 cbc99cea>;
Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>;
}
Jul 19 11:25:00 iPhone abcProject-Production[211] <Warning>: Unresolved error Optional(Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo=0x168e0c90 {NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x16b05350 "The operation couldn’t be completed. (Cocoa error 134130.)", NSLocalizedFailureReason=There was an error creating or loading the application's saved data.}), [NSLocalizedDescription: Failed to initialize the application's saved data, NSUnderlyingError: Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)"
UserInfo=0x16b05490 {URL=file:///var/mobile/Containers/Data/Application/B12FCDA6-C91B-487E-8D03-CBBEB884996D/Documents/abcProject, metadata={
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
TabBanner = <3722cf8b 4ac58f43 20c84d7e 7d66865d a1382ecc 1ab25190 7b7c3fa7 843813fe>;
Video = <c51795f8 140c4936 de1b7615 03a944e7 f2b0451f 3c0b5887 2cfb31d3 07610d22>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "79788D63-BEF2-4339-BF60-1580904D9B44";
"_NSAutoVacuumLevel" = 2;
}, reason=Can't find model for source store}, NSLocalizedFailureReason: There was an error creating or loading the application's saved data.]
Jul 19 11:25:01 iPhone ReportCrash[212] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)
Jul 19 11:25:01 iPhone ReportCrash[212] <Notice>: ReportCrash acting against PID 211
Jul 19 11:25:01 iPhone ReportCrash[212] <Notice>: Formulating crash report for process abcProject-Production[211]
Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: BSXPCMessage received error for message: Connection invalid
Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: Unable to get short BSD proc info for 211: No such process
Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: Unable to get short BSD proc info for 211: No such process
Jul 19 11:25:01 iPhone mediaserverd[37] <Notice>: '' com.abcProject(pid = 211) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Jul 19 11:25:01 iPhone wifid[69] <Notice>: WiFi:[490600501.266659]: Foreground Network Application exited.
Jul 19 11:25:01 iPhone AppStore[175] <Warning>: [SSMetricsEventController] Direct-access controller is calling through XPC to flush Unreported Events
Jul 19 11:25:01 iPhone wifid[69] <Notice>: WiFi:[490600501.267352]: BG Application: Not Present, BG Daemon: Present. Daemons: apsd itunesstored networkd
Jul 19 11:25:01 iPhone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jul 19 11:25:01 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.abcProject[0xb6e0][211]) <Notice>: Service exited due to signal: Abort trap: 6
Jul 19 11:25:01 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.abcProject[0xb6e0]) <Notice>: Service only ran for 6 seconds. Pushing respawn out by 2147483641 seconds.
Jul 19 11:25:01 iPhone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jul 19 11:25:01 iPhone SpringBoard[43] <Warning>: Application 'UIKitApplication:com.abcProject[0xb6e0]' crashed.
Jul 19 11:25:01 iPhone assertiond[58] <Warning>: pid_suspend failed for <BKNewProcess: 0x1668b480; com.abcProject; pid: 211; hostpid: -1>: Unknown error: -1, Unknown error: -1
Jul 19 11:25:01 iPhone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x1668b480; com.abcProject; pid: 211; hostpid: -1> to 2, priority: No such process
Jul 19 11:25:01 iPhone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x1668b480; com.abcProject; pid: 211; hostpid: -1> to 4096, priority: No such process
Jul 19 11:25:01 iPhone UserEventAgent[17] <Warning>: id=com.abcProject pid=211, state=0
Jul 19 11:25:01 iPhone ReportCrash[212] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/abcProject-Production_2016-07-19-112501_iPhone.ips
Jul 19 11:25:06 iPhone wifid[69] <Notice>: WiFi:[490600506.681414]: WiFi unquiescing requested by "locationd"
Jul 19 11:25:06 iPhone wifid[69] <Notice>: WiFi:[490600506.686744]: WiFi unquiescing requested by "locationd"
Jul 19 11:25:06 iPhone wifid[69] <Notice>: WiFi:[490600506.743193]: WiFi unquiescing requested by "locationd"
Jul 19 11:25:08 iPhone wifid[69] <Notice>: WiFi:[490600508.843256]: Client itunesstored set type to normal application
Jul 19 11:25:08 iPhone wifid[69] <Notice>: WiFi:[490600508.844080]: __WiFiManagerSetEnableState: state TRUE, manager->enable.setting TRUE, manager->unlockedSinceBoot TRUE
Jul 19 11:25:08 iPhone wifid[69] <Notice>: WiFi:[490600508.845449]: BG Application: Not Present, BG Daemon: Present. Daemons: apsd networkd
Jul 19 11:25:09 iPhone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jul 19 11:25:12 iPhone aggregated[29] <Warning>: Scheduling parameters: 0 minutes before midnight, 4.0 time(s)/day
Jul 19 11:25:12 iPhone aggregated[29] <Warning>: delay: 595 into interval 21600 => 22195
Jul 19 11:25:12 iPhone aggregated[29] <Warning>: Next ADDaily run scheduled in 06:09:55 at 2016-07-19 12:05:07 +0000
Jul 19 11:25:12 iPhone addaily[213] <Warning>: addaily started
Jul 19 11:25:12 iPhone addaily[213] <Warning>: daily tasks for day 17000
Jul 19 11:25:13 iPhone addaily[213] <Warning>: Filtering only beta sessions
Jul 19 11:25:13 iPhone addaily[213] <Warning>: Saved Sessions as /var/mobile/Library/Logs/CrashReporter/log-sessions-2016-07-19-112513.session
Jul 19 11:25:23 iPhone addaily[213] <Warning>: addaily ended
The error, Can't find model for source store says that when the app tried to migrate the persistent store, it could not find the data model that had been used to create the store. Data migration requires both the old and new data stores. The old one is used to load the data, and the new one is used to update the data for future use.
The reason this works on iOS 9 is that iOS 9 added model caching for use in lightweight migrations of SQLite stores. On iOS 9 you can therefore get a successful migration without the old model, because the old version will be automatically cached. This feature was not available on iOS 8, so if you're still supporting 8 then you still need to include the old version of the model in your app.
Finally I got it resolved by doing a simple change .
Earlier code :-
url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject1")
Fixed code :-
url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject1.sqlite")
adding <.sqlite> extension to my url path solved the issue for me.
It is fully tested with all the possible scenarios.
Thank you all for your help.
To avoid the crash I created new database for iOS 8 because I didnt need existing data that much.
I changed my storeURL from
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject")
to
let url:NSURL
if (OS_VERSION<9.0)
{
url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject1")
}
else
{
url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("abcProject")
}
This fixed the crash for me.