Forcing a saved image to sync with the iCloud Photo Stream - ios

I have an app that takes images periodically, and I would like them to be uploaded to the iCloud Photo Stream right after the images are taken.
It appears that certain conditions need to be met in order for this to work. It only seems to work when running iOS 8, the device is connected to wireless, and by using UIImagePickerController to take pictures (rather than AVCapture) at least once. It seems that the UIImagePickerController when presented alters some system settings that allows for subsequent automatic uploading of images to the iCloud Photo Stream. If I use AVCapture only to take pictures, it will not work. I've confirmed that "Upload to My Photo Stream" is enabled in the iCloud settings, and there is an active wireless connection.
Here is the method used to save an image obtained from UIImagePickerController:
- (void)saveImage : (UIImage *)image {
// Add image to the photo library
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetChangeRequest =
[PHAssetChangeRequest creationRequestForAssetFromImage:image];
} completionHandler:^(BOOL success, NSError *error) {
if (!success)
NSLog(#"Error creating asset: %#", error);
}];
}
When running on my iPad with iOS 8, below are the entries that I see in the device system logs:
Oct 22 21:11:06 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Submitting 1 asset collections for publication.
Oct 22 21:11:06 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
Oct 22 21:11:10 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx uploading 1 assets...
Oct 22 21:11:11 iPad mstreamd[14409] <Notice>: (Note ) PS: Received push notification for invitations topic: com.apple.mediastream.subscription.push userInfo: {
r = xxxxxxxx;
}
Oct 22 21:11:11 iPad mstreamd[14409] <Notice>: (Note ) PS: <MSIOSMediaStreamDaemon: 0x1662ad80>: Push notification received for My Photo Stream with targetPersonID xxxxxxxx.
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1666fae0>: Plugged in to external power. Allowing file transfers.
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x1666fae0>: Push received. Allowing file transfers to continue for 60.00 seconds
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
Oct 22 21:11:12 iPad mstreamd[14409] <Notice>: (Note ) PS: MSSubscriber - xxxxxxxx Found 1 new asset collections.
Oct 22 21:11:13 iPad assetsd[11536] <Warning>: Unable to open file to save extended attributes (No such file or directory).
When running on my iPhone with iOS 9.1, I have similar log entries, except I have additional warnings/error messages about the caching server bolded:
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Submitting 1 asset collections for publication.
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...
**Oct 25 22:35:28 iPhone AssetCacheLocatorService[1658] <Warning>: #df99fdd0 [I:AssetCacheLocatorService.queue] found no caching servers**
Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx uploading 1 assets...
**Oct 25 22:35:28 iPhone mstreamd[1735] <Notice>: (Error) mmcs: __mmcs_proxy_locator_exists_block_invoke:167 might have caching server returned with error: Error Domain=NSPOSIXErrorDomain Code=60 "Operation timed out" UserInfo={com.apple.AssetCacheLocator.tag=#1963bd2d, NSLocalizedDescription=quick miss requested}**
**Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSPublisher - xxxxxxxx Sending metadata...**
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: Received push notification for invitations topic: com.apple.mediastream.subscription.push userInfo: {
r = xxxxxxxx;
}
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: <MSIOSMediaStreamDaemon: 0x157e0c530>: Push notification received for My Photo Stream with targetPersonID xxxxxxxx.
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x157e84410>: Plugged in to external power. Allowing file transfers.
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) mstreamd: <MSPowerBudget: 0x157e84410>: Push received. Allowing file transfers to continue for 60.00 seconds
Oct 25 22:35:29 iPhone mstreamd[1735] <Notice>: (Note ) PS: MSSubscriber - xxxxxxxx Found 1 new asset collections.
Oct 25 22:35:30 iPhone assetsd[1624] <Warning>: Unable to open file to save extended attributes (No such file or directory).
In this situation with iOS 9, the image is not uploaded when my app is active, and is uploaded only when the app goes into the background.
I suspect that the issue is due to 1. some system setting that is is activated with presentation of the UIImagePickerController only in iOS8 or 2. some issue with caching servers in iOS 9 as suggested by the log entries.
Anyone have any idea what is going on? Any ideas would be greatly appreciated! Thanks!

I think I've found a solution. It seems that if an AVCaptureSession is running, the iCloud Photo Stream will not synchronized. Calling the stopRunning method (as below) seems to do the trick:
[self.cameraSession stopRunning];

Related

iOS Meteor Cordova app: all app graphics disappear after a few minutes

I've got a working Meteor Cordova app that installs and runs on both iOS and Android devices. However, on iOS only, and only if the iPhone is not plugged into xCode, all of the graphic assets disappear from the app and show as nothing -- no broken pic image or box outline or different color, just the color of the background as though nothing was ever there. They don't disappear while you stare at the current screen, you have to go to a different screen or leave and return to the app, but once it happens, all the graphics are gone. It doesn't even affect formatting of page content. Just poof, no more graphics.
Since it's on-device only and doesn't happen if plugged into xCode, I haven't been able to get any possible error messages. Plus, the app still works fine. And if I kill the app and restart it, the icons all come back.
Maybe this is a behavior of the internal web server that Cordova does to get around the WKWebView-no-local-assets issue? Maybe it's a code issue (I've had another iOS-only issue that was a string vs number thing in how iOS and Android act differently). But since I can only reproduce it on-device and without connection to debugging, I'm hoping someone knows the answer.
I keep all of my graphics in /public/images, if that's a clue. But the fact that it doesn't happen on Android is really a stumper.
UPDATE:
More info. I've used Xcode to examine the console log and found these log entries that clearly show the image resources are being successfully retrieved.
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6275] <Notice>: TIC TCP Conn Event [162:0x12bd42470]: 1 Err(0)
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6275] <Notice>: TIC TCP Conn Connected [162:0x12bd42470]: Err(0)
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6275] <Notice>: TIC TCP Conn Cancel [162:0x12bd42470]
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6275] <Notice>: TIC TCP Conn Destroyed [162:0x12bd42470]
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.WebContent(WebKit)[6276] <Notice>: 0x10e2f1148 - WebResourceLoader::didReceiveResponse: (pageID = 2, frameID = 1, resourceID = 239, status = 200)
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.WebContent(WebKit)[6276] <Notice>: 0x10e2f1148 - WebResourceLoader::didReceiveData: Started receiving data (pageID = 2, frameID = 1, resourceID = 239)
Jan 4 15:06:00 Andys-iPhone-7 com.apple.WebKit.WebContent(WebKit)[6276] <Notice>: 0x10e2f1148 - WebResourceLoader::didFinishResourceLoad: (pageID = 2, frameID = 1, resourceID = 239)
but then when the problem occurs, the log is this:
Jan 4 14:31:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6252] <Notice>: TIC TCP Conn Event [141:0x159e0d9f0]: 3 Err(61)
Jan 4 14:31:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6252] <Error>: TIC TCP Conn Failed [141:0x159e0d9f0]: 1:61 Err(61)
Jan 4 14:31:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6252] <Notice>: TIC TCP Conn Cancel [141:0x159e0d9f0]
Jan 4 14:31:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6252] <Notice>: TIC TCP Conn Destroyed [141:0x159e0d9f0]
Jan 4 14:31:00 Andys-iPhone-7 com.apple.WebKit.Networking(WebKit)[6252] <Notice>: 0x103184b40 - NetworkResourceLoader::start: Retrieving resource from cache (pageID = 2, frameID = 1, resourceID = 224, isMainResource = 0, isSynchronous = 0)
Jan 4 14:31:00 Andys-iPhone-7 com.apple.WebKit.Networking(CFNetwork)[6252] <Error>: HTTP load failed (error code: -1004 [1:61])
The -1004 error is cannot connect to host. So, this app is successfully getting images from, I think, the internally existing content server, but that breaks after a few minutes.
Does anyone have any ideas? Meteor 1.6, newest xCode, iOS 10, btw. Thanks!
Found the answer on the Meteor forum. In writeups like this:
https://github.com/meteor/cordova-plugin-meteor-webapp/issues/27
it's confirmed that there are issues with the plugin that provides the embedded content server, and macrozone has provided a fix. Install this in your project:
meteor add cordova:cordova-plugin-meteor-webapp#https://github.com/panter/cordova-plugin-meteor-webapp.git#7bb095ce393d17f662cc6bb596ce91acf743d17a
This solves this issue and maybe some white screen of death meteor cordova issues, too. Kudos to macrozone!

Xcode disconnecting from simulator or device when going to homescreen

I'm trying to debug an handoff issue in Xcode, but the debugger disconnects every time I go to the device homescreen. This happens on both the simulator and an actual device.
I have other apps where it works correctly; that is, it continues to debug when I go to the homescreen.
Any ideas what could be causing this? I've rebooted Xcode and my Mac with no luck.
When running on the device, the log has a message that looks like:
Jun 28 16:36:31 Mikes-iPhone com.apple.debugserver-#(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[14593] <Warning>: 1 +0.000000 sec [3901/1307]: error: ::read ( -1, 0x16e246a38, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Jun 28 16:36:31 Mikes-iPhone com.apple.debugserver-#(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[14593] <Warning>: Exiting.
Jun 28 16:36:31 Mikes-iPhone mediaserverd[14247] <Notice>: '' com.zzzzzz.appname(pid = 14594) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
I'd appreciate any ideas or suggestions....
Well this was dumb. At some point I had changed the "Application does not run in background" plist flag to YES. Simply changing to NO fixed the problem. Duh.

Crash iOS application

My application crash sometimes but I can't reproduce this, and I don't know the reason of crash. Below a link for what I found in crash file (ips):
http://we.tl/SRb84J750O
And in logs I found that
SpringBoard[197] <Warning>: HW kbd: Failed to set (null) as keyboard focus
Dec 6 15:56:16 DreamIt backboardd[55] <Warning>: |GAXGeneral|info| Did verify event: [Guided Access App Did go Invalid]. Outcome: [In Progress - Delayed].
Dec 6 15:56:16 DreamIt mediaserverd[190] <Notice>: '' com.parisinside(pid = 359) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Dec 6 15:56:16 DreamIt mediaserverd[190] <Notice>: '' com.parisinside(pid = 359) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Dec 6 15:56:17 DreamIt mediaserverd[190] <Notice>: 'FigPlayer - 389' (pid = 389) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Dec 6 15:56:17 DreamIt UserEventAgent[23] <Notice>: jetsam: kernel termination snapshot being created
Dec 6 15:56:17 DreamIt ReportCrash[968] <Warning>: saved type '298' report (1 of max 25) as /var/mobile/Library/Logs/CrashReporter/JetsamEvent-2015-12-06-155617.ips
Dec 6 15:56:17 DreamIt SpringBoard[197] <Warning>: Application 'UIKitApplication:com.parisinside[0xa877]' was killed by jetsam.
Dec 6 15:56:17 DreamIt UserEventAgent[23] <Warning>: 375564219023: id=com.parisinside pid=359, state=0
Dec 6 15:56:17 DreamIt SpringBoard[197] <Warning>: [MPUSystemMediaControls] Updating supported commands for now playing application.
Dec 6 15:56:17 DreamIt backboardd[55] <Warning>: |GAXGeneral|info| Did verify event: [Guided Access App Did go Invalid]. Outcome: [Success - Session App is Frontmost].
Dec 6 15:56:17 DreamIt searchd[969] <Alert>: (Error) IndexGeneral in si_playBackMobileRecords:2313: played back 1 records
Dec 6 15:56:18 DreamIt searchd[969] <Alert>: (Error) IndexGeneral in si_playBackMobileRecords:2313: played back 1 records
Dec 6 15:56:18 DreamIt searchd[969] <Alert>: (Error) IndexGeneral in si_playBackMobileRecords:2313: played back 2 records
Dec 6 15:56:18 DreamIt searchd[969] <Warning>: ====^^^^ DuetExpert missing data, count -> people:0 applicationDeepLinks:0 applications:8 requests:1 missingAllDataRequests:0
Dec 6 15:56:18 DreamIt SpringBoard[197] <Warning>: Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x15f039b90 V:[UIView:0x15f029410]-(-1)-| (Names: '|':UITableViewCellContentView:0x15f7ab4c0 )>",
"<NSLayoutConstraint:0x15f6dbae0 V:[UIView:0x15e4abc40]-(0)-| (Names: '|':UIView:0x15f029410 )>",
"<NSLayoutConstraint:0x15e3cae20 UIView:0x15e4abc40.top == UITableViewCellContentView:0x15f7ab4c0.top>",
"<NSLayoutConstraint:0x15f7387c0 V:[UIView:0x15e4abc40(119)]>",
"<NSLayoutConstraint:0x15e327a20 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x15f7ab4c0(117.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x15f7387c0 V:[UIView:0x15e4abc40(119)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Dec 6 15:56:18 DreamIt tccd[192] <Notice>: Refusing client without bundle identifier (/usr/libexec/duetexpertd)

Persistent store migration on iPhone 5s crashes tableview

I have a relatively straightforward master detail application in Xcode 6.0.1 with iOS Simulator 8.0.
The application uses core data. The application is local only. I plan to use iCloud or Dropbox to backup
the data, but not for synchronization. At the moment it is local only.
Everything works beautifully with one huge exception. Every time I use the simulator and simulate iPhone 5s,
as soon as I migrate the store and then access the tableview detail, the app crashes. No log info, no error info,
it simply stops. Same is true for a 5s phone.
If I run the simulator in iPhone 5 mode, or run the app on an iPhone 4s it works perfectly. I've read dozens of
tutorials and articles about core data and the persistent store - never even heard of this issue.
So there must be some issue for post- persistent-store migration on the 64 bit devices. Can anyone help?
(void)migrateStore:(NSString *)newSQLFileName {
// migrate current store from one URL to another
// write out the current store URL before the migration
NSURL *storeURL = [self.persistentStoreCoordinator.persistentStores.lastObject URL];
NSLog(#"storeURL before migration: %#", [storeURL description]);
// get the current store
NSPersistentStore *currentStore = self.persistentStoreCoordinator.persistentStores.lastObject;
// create a new URL
NSURL *newStoreURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:newSQLFileName];
//add the options dictionary once you get it working
// migrate current store to new URL
[self.persistentStoreCoordinator migratePersistentStore:currentStore toURL:newStoreURL options:nil withType:NSSQLiteStoreType error:nil];
// check to see if the new store is active, write out the URL again
storeURL = [self.persistentStoreCoordinator.persistentStores.lastObject URL];
NSLog(#"storeURL after migration: %#", [storeURL description]);
}//migrateStore:newSQLFileName
from the debug log window:
2014-10-02 16:35:09.274 BiopLog[31758:2509702] User entered PIN to validate
2014-10-02 16:35:09.277 BiopLog[31758:2509702] ** User Authenticated!!
2014-10-02 16:35:09.389 BiopLog[31758:2509702] the document path is: /Users/john_grauel/Library/Developer/CoreSimulator/Devices/25BCE099-41D2-4679-9A40-615656159E84/data/Containers/Data/Application/39A5A3FF-CBDE-42A0-B6BA-DBC632EE0E31/Documents
2014-10-02 16:35:12.384 BiopLog[31758:2509702] storeURL before migration: file:///Users/john_grauel/Library/Developer/CoreSimulator/Devices/25BCE099-41D2-4679-9A40-615656159E84/data/Containers/Data/Application/39A5A3FF-CBDE-42A0-B6BA-DBC632EE0E31/Documents/BiopLog.sqlite
2014-10-02 16:35:12.843 BiopLog[31758:2509702] storeURL after migration: file:///Users/john_grauel/Library/Developer/CoreSimulator/Devices/25BCE099-41D2-4679-9A40-615656159E84/data/Containers/Data/Application/39A5A3FF-CBDE-42A0-B6BA-DBC632EE0E31/Documents/BiopBak201410021635.sqlite
(lldb)
and the Devices log includes:
Oct 2 17:42:41 JohniPhone SpringBoard[48] : Application 'UIKitApplication:com.carbonrose.BiopLog[0x9dbb]' crashed.
Oct 2 17:42:41 JohniPhone assertiond[58] : pid_suspend failed for : Unknown error: -1, Unknown error: -1
Oct 2 17:42:41 JohniPhone assertiond[58] : Could not set priority of to 2, priority: No such process
Oct 2 17:42:41 JohniPhone assertiond[58] : Could not set priority of to 4096, priority: No such process
Oct 2 17:42:41 JohniPhone UserEventAgent[17] : id=com.carbonrose.BiopLog pid=886, state=0
Oct 2 17:42:41 JohniPhone locationd[55] : Location icon should now be in state 'Active'
Oct 2 17:42:41 JohniPhone geod[127] : Can't get bundle identifier for process 565
Oct 2 17:42:43 JohniPhone locationd[55] : Gesture EnabledForTopCLient: 1, EnabledInDaemonSettings: 0
Oct 2 17:42:43 JohniPhone kernel[0] : xpcproxy[888] Container: /private/var/mobile/Containers/Data/Application/EC6B60D8-510D-4E46-82B1-29891D0F4E79 (sandbox)
Oct 2 17:42:43 JohniPhone yweather[888] : assertion failed: 12A405: libxpc.dylib + 71820 [4BC9CA3D-4DEE-314C-ADBF-53BDCEEFE45C]: 0x7d
Oct 2 17:42:43 JohniPhone Unknown[888] :
Oct 2 17:42:43 JohniPhone yweather[888] : CFURLSetResourcePropertyForKey failed because it was passed this URL which has no scheme: /var/mobile/Containers/Data/Application/EC6B60D8-510D-4E46-82B1-29891D0F4E79/Documents/YI13N/sqlite/yi13nevents.db
Oct 2 17:42:43 JohniPhone yweather[888] : Enabling Crittercism v4.3.4...
I had created an sqlite file with sample data and loaded that file when initializing the app. the difference in the storage of numbers from the 32 bit to the 64 bit machines was the reason the process was failing. The solution is to read in data from code and if later necessary, migrate the core data store to another device. the migration process will create the correct number storage locations.

mobile_house_arrest[xxx] <Error>: Max open files: 78

I'm using UIWebView as a wrapper around my html5 application. Application implements a lot of video streaming - and is medium size (JS code).
When I actively use it I receive a lot of errors:
Jul 31 13:21:34 iPad mobile_house_arrest[483] <Error>: Max open files: 78
Jul 31 13:21:34 iPad mobile_house_arrest[485] <Error>: Max open files: 78
...
Jul 31 13:21:35 iPad mobile_house_arrest[505] <Error>: Max open files: 78
in the device's console - and it stops to respond. Meantime it works great in Safari browser on the same device.
Is there any known memory leak issue or better workaround that I can apply?
You might be using "fopen" or "NSFileHandle"..etc to create file handles but you are not closing them appropriately (eg if you are using FILE * fopen ( const char * filename, const char * mode ) then you should close file using fclose ( FILE * stream ))".Only max 78 files can be opened simultaneously in iPhone device.

Resources