Posts

Post not yet marked as solved
1 Replies
472 Views
TL;DR: I'm syncing a local database to CloudKit and I'd like to store only the CKRecord's recordChangeTag locally, because the archived system fields are quite large. Is there any way to create a CKRecord with a given recordChangeTag? I'm working on syncing an on-device database to CloudKit. As part of this I need to remember the CloudKit state of every database record, so I when that record changes I can create a CKRecord for it and push it to the server. The supported way to do this is to call CKRecord.encodeSystemFields on the resulting record after the push, and save that archived data alongside the local record so it can be reconstituted into a CKRecord next time I need to push that database row. The problem is that this archived data is pretty heavyweight, generally about 1600 bytes. That's not a lot for one record, but for 60,000 records it's 100MB of extra data to store (and read and write.) As far as I can tell, the only really crucial part of a CKRecord to push (besides the ID and type, which I already know) is the recordChangeTag — this is what the server uses as the MVCC token to reject conflicting updates. And this tag is tiny: it appears to be a hex-encoded generation count, so it's usually 1 or 2 bytes. I'd like to store just this tag. But I can't use it to reconstitute a CKRecord, because that property isn't settable. Is there any workaround?
Posted
by snej.
Last updated
.
Post not yet marked as solved
2 Replies
1.3k Views
I'm adding a WKWebView to my (Mac) app, and it works fine except that the navigationDelegate is never called. Even stranger, if that delegate implements decidePolicyForNavigationAction, that method is never called either, but as a side effect the view now won't load any pages! In detail: I've created a class implementing WKNavigationDelegate, I've implemented some of the methods, and assigned an instance to the view's navigationDelegate property. Easy stuff. I've done this in the past using the old-school WebView class. I've triple-checked my work. As an experiment, I added a -respondsToSelector: method to my delegate class and made it log the selector. I see it being called several dozen times, with the selectors for all of the delegate methods and many other private(?) methods; so I know WebKit sees my object. It just never calls it at all. My hunch so far is that this is an OS bug, that Apple no longer bothers to test WebKit APIs in Objective-C. I'd hate for that to be true. (I realize Obj-C is basically deprecated nowadays. I'm using it because my non-UI code is all in C++, and it's vastly easier to integrate with C++ in Obj-C. To use Swift I'm going to have to wrap my API in C functions, yuck.)
Posted
by snej.
Last updated
.
Post not yet marked as solved
0 Replies
850 Views
I’m trying to implement a simple cross-process notify/observe system, using a pthread mutex and condition variable in shared (mapped) memory. It seems to be working fine (on macOS 11.6) if one process calls pthread_cond_wait and then another calls pthread_cond_broadcast — the waiting process indeed wakes up. However, if two processes try to observe at the same time, the second one's call to pthread_cond_wait fails with EINVAL. I’m wondering if I’m just doing something wrong in my setup, or if this sort of usage isn’t supported. Basically I create and mmap a file, initialize a pthread mutex and condition in the mapped memory using the setpshared attributes, then lock the mutex and notify or wait on the condition. Actual source code here: Here’s the code that does the pthreads stuff Here’s the outer code that opens and mmaps the file I’m aware that there are a few dozen 🙄 Apple IPC APIs that are probably preferred over these POSIX ones. I’ve used some in the past. I’m doing it this way because: (a) this is in a cross-platform project and it would be nice to share code between Unix platforms, at least Darwin and Linux; (b) the thing I’m notifying/observing about is a database file, so tying the notifications to a side file next to the database provides ideal scoping; (c) it’s similar in principle to the usage of shared memory for locking in SQLite and LMDB. (The difference is, I’m doing notification not locking.) Any advice? —Jens
Posted
by snej.
Last updated
.
Post marked as solved
2 Replies
931 Views
I need to get the list of trusted root certificates, but for some reason the function SecTrustCopyAnchorCertificates is not available on iOS. Is there any workaround?We need the list because we have a large cross-platform codebase that uses the open-source mbedTLS library to run TLS connections. The mbedTLS API requires being given a list of root certs. It does not have a callback for evaluating the trust of a cert, so it's not feasible to plug SecTrust into it.In an earlier thread on this topic it was suggested to copy Apple's published list of certs and paste it into the app. That's bad security: root certs can and do get revoked, and of course they expire and new ones can be added, so the root cert list has to be a dynamic entity that can be updated on the fly. Hardcoding a copy into an app puts that app developer on the hook for updating their app to fix security issues involving the global root cert list. Hardcoding it into a library (in our case) would put all of our users/customers in that situation.I've never understood why SecTrustCopyAnchorCertificates wasn't added on iOS. These certs are public knowledge, so how can making them available be a security issue? I suspect it's done to keep people from using non-Apple cert/trust APIs, and ordinarily I do believe in using platform APIs, but when we have a large complex codebase that has to support everything from iOS to Android to Windows 10 to CentOS, that doesn't always work out.--Jens
Posted
by snej.
Last updated
.