There is LazyVStack to work with a large amount of content inside a ScrollView and ensure good scrolling performance.
I like to work with List in my apps as it provides some more functionality than just a ScrollView with a stack of content inside.
Does List in SwiftUI now also use lazy loading of content elements in iOS 14?
If it does not support this by default is there any way to make it work with lazy loaded content?
I tried this code but it caused rendering issues:
List {
LazyVStack {
Text("1")
// [...] hundreds of Text views for testing
}
}
Post not yet marked as solved
Since Big Sur, my dock is unhiding too quickly (although everything else since updating is running too slowly).
I need a bit of delay when I am using the mouse on a bottom scrollbar. Otherwise, I keep accidentally dragging my icons around in my dock. Any way to slow down or delay the unhiding of my dock?
Post not yet marked as solved
Attempting to find nominal CPU clock frequency. Previously have been finding this using sysctlbyname() with name="hw.cpufrequency" or with sysctl() with name[0]=CTLHW and name[1]=HWCPU_FREQ. I also notice that processor speed no longer shows in 'About this Mac'. Anyone know I programmatically find this value on an M1 machine?
Post not yet marked as solved
Hello,
Since Xcode 12, I can't see the test report popup when running performance tests. Therefore, I am not able to set the baseline anymore. This used to work fine in Xcode 11.
Here's an example:
swift
func testStoragePerformance() throws {
let application = XCUIApplication()
application.launch()
let storageMetric = XCTStorageMetric(application: application)
self.measure(metrics: [storageMetric]) {
self.runUIFlow(application: application)
}
}
When running the test above, Xcode shows the test as successful and that's it... Same thing happens with XCTCPUMetric and XCTMemoryMetric. It seems to only work with XCTClockMetric (baseline can be set then).
I am able to reproduce this bug on a new project created in Xcode 12.4.
I have reached out to people at Apple and also created a ticket in Feedback Assistant but I've never got any response.
Is anyone else experiencing the same issue? Is this a known bug?
Thanks
Post not yet marked as solved
MacBook Pro 13" (2015) needed new battery. To drain existing battery I let MacBook on, but also update OS X to Big Sur. Replaced battery and charged it. Upon boot, all worked but not keyboard. Trackpad works but keyboard doesn't. Replaced track pad cable, but keyboard is still nil. Any suggestions? Many thanks!
Post not yet marked as solved
Hi there,
I previously experienced a massive memory leak in SwiftUI on macOS which now seems to be fixed. CLICK - https://developer.apple.com/forums/thread/676860
But my app still becomes slower and memory footprint grows after some time of using it. I was able to created a new minimal but more extreme example to reproduce:
This is a full app for SwiftUI. Compile for macOS (I'm using Xcode 12.4 macOS 11.2.3)
import SwiftUI
@main
struct DemoApp: App {
@State var strings = ["Hello 1", "Hello 2"]
@State var bool = false
let timer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()
@State var selected: Int?
var body: some Scene {
WindowGroup {
List(strings.indices, id: \.self, selection: $selected) { stringIndex in
Text(strings[stringIndex])
}
.toolbar(content: {
ForEach(1...100, id: \.self) { _ in
Text("Hello World")
}
})
.onReceive(timer) { input in
if bool == true { selected = 0 }
else { selected = 1 }
bool = !bool
}
}
}
}
Timer is optional but it will show the problem more quickly. It seems to be connected to toolbar content a lot.
Memory footprint quickly goes up, as well as CPU utilization & app slows down significantly just after a few seconds. Please help! What can I do? My app is pretty much not usable because of this bug.
Johannes
Since upgrading to Big Sur, sending AppleScript "do JavaScript" command to Safari runs extremely slowly.
For example:
tell application "Safari"
set rslts to do JavaScript "document.title;" in document 1
end tell
... this used to take a split second in prior versions of the MacOS. Since upgrading to Big Sur, running this script results in a spinning pinwheel, the Safari's CPU usage ramps up to 100% and the command takes about 10 seconds to complete.
Post not yet marked as solved
Hi
I am developing an app with swiftUI. Here is the code of a map view. I create customized annotations and show them on the map view. The issue is that when I drag or zoom in/ out on the map view. The app is so slow. The fps decrease to about 20 - 30 from 60. I use instruments to analyze this app. The result shows that there are thousands of times annotation render. I think that the reason for this issue may be off-screen rendering. But I don't know how to solve it. Looking forward to your help.
swift
Map(coordinateRegion: $region, interactionModes: .all, showsUserLocation: true, userTrackingMode: $trackingMode, annotationItems: result, annotationContent: { mark in
MapAnnotation(coordinate: CLLocationCoordinate2D(latitude: mark.lat, longitude: mark.long)) {
Button {withAnimation {
self.selectedGymUid = Int(mark.uid)
}} label: {RoundedGymIconOnMapView(name:mark.name)
.clipShape(Circle())
.overlay(Circle().stroke(selectedGymUid == Int(mark.uid) ? Color(.green).opacity(0.5) : AppColor.shared.joggingColor.opacity(0.5),lineWidth: 1.4))
.scaleEffect(selectedGymUid == Int(mark.uid) ? 2 : 1)
.shadow(radius: 5) }
}
})
Post not yet marked as solved
This is a follow up to feedback FB9144718, which we also discussed at a WWDC21 "Performance, power, and stability" lab session.
Issue Summary
The actual issue we are facing is that our XPC service is not running as fast as we would expect it to be, especially not on Intel machines; somewhat better on M1 machines but still not really good.
After a lot of profilling with instruments, it finally turned out that the problem is caused by our processing getting regularly stopped as our processing thread is being preempted and put on hold for sometimes a tramendous amount of time (up to over 32 ms have been monitored). Even it is preempted for just a couple of ms most of the time, this is still a lot considering that the actual work it would otherwise perform is only in the range of microseconds.
The reason why this is happening is probably caused by the fact that we don't use the XPC service just for processing application messages through the XPC protocol, which we do as well, but also retrieve requests through a mach port from another process.
This causes our thread priority to be dropped down to 4 (see highlighted log line) and that's the reason why we get preempted for so long. The reason why it's not equally dramatic on M1 is that we are not preempted there, instead we are forced to run on the high efficiency cores instead of the high performance ones.
Ideas from the Lab
Other than completely restructuring our entire implementation which is eventually going to happen in the future anyway for Big Sur and newer, we still have to maintain this structure as long as we need to also support pre-Big Sur macOS version, so it would be great to have a less dramatic fix.
Two suggestions were made at the lab:
Change the RunLoopType in the XPC Plist from dispatch_main to NSRunLoop. We tried that but that didn't made any difference.
Add a key ProcessType with the value Interactive to the XPC Plist. This key is not documented for XPC services, only for launchd daemons but we were told it should actually work for XPC services as well. We tried that as well, both, top level as well as adding it to the XPC sub-key but that didn't make a difference either.
Another Idea That Didn't Work
Now that second suggestion made me look up that key in the man page for launchd.plist and what I found there was pretty interesting. Apparently there is a ProcessType value documented as
Adaptive
Adaptive jobs move between the Background and Interactive classifications based on activity over XPC connections. See xpc_transaction_begin(3) for details.
This seems to be our problem. Our XPC service is considered inactive when it processes messages over the mach port. Looking up the documentation of xpc_transaction_begin(3) tells me:
Services may extend the default behavior using xpc_transaction_begin() and xpc_transaction_end(), which increment and decrement the transaction count respectively. This may be necessary for services that send periodic messages to their clients, not in direct reply to a received message.
Using these two messages also frees us from the requirement to enable/disable sudden termination our own as it will automatically be controlled by these two functions as well. Yet even using these two functions to indicate activity doesn't prevent us from being preempted at regular intervals as our priority still drops to priority level 4 while we are still in the middle of processing (haven't called xpc_transaction_end() yet) . We seem to use it correctly though as it correctly disables sudden termination on our behalf as long as our XPC service remain in the active state (it will only receive mach messages for processing while in that state) and also gets re-enabled when we leave the active state again.
Final Thoughts
Also on the man page of xpc_transaction_begin() is written:
The XPC runtime will also automatically manage the service's priority based on where a message came from. If an app sends a message to the service, the act of sending that message will boost the destination service's priority and resource limits so that it can more quickly fill the request. If, however, a service gets a message from a background process, the service stays at a lower priority so as not to interfere with work initiated as a direct result of user interaction.
It looks like this is not working the way we use the XPC service at the moment. Our mach port messages either come from a System Extension (Big Sur and up) or from a root daemon started by launchd (Catalina and below, ProcessType is Interactive and nice value is -10) but apparently these messages cannot boost our XPC service and so it will stay on low prio.
Post not yet marked as solved
I've been having this issue with X-Code for years and have never found a fix. I've seen many people post this issue but no solutions that work.
When typing in X-Code, ever few letters I type the editor just hangs, sometimes the rainbow beachball spinner even comes up. Just pressing return takes a second to complete. Any ideas? There's got to be a fix for this
Hi!
I'm desperately looking for the documentation on using MetricKit REST API, and download diagnostics and metrics data on my server for analysis and visualisations.
At the moment, there's very little of documentation on MetricKit, and it's limited to the usage on device.
Please, help me to find the documentation on how to use REST API for it 🙏
There's awesome video from WWDC2020 about it (https://developer.apple.com/wwdc20/10057), but the promised documentation can not be found 😅
Post not yet marked as solved
system dead lock sometimes ,is there anyone who can help me , i v got none idea.
Incident Identifier: DD02C50E-9062-4019-B5B6-098C25E2CF45
CrashReporter Key: 3d6dae79d882333702c0582e86fb6adafae3dd8c
Hardware Model: iPhone7,2
Process: xxxx [3454]
Path: /private/var/containers/Bundle/Application/BB2155C4-7AE2-4C09-8A2A-982B6825D576/xxxx.app/xxxx
Identifier: xxxxx
Version: 206 (1.0.0)
Code Type: ARM-64 (Native)
Role: Non UI
Parent Process: launchd [1]
Coalition: xxxxxx [4505]
Date/Time: 2021-07-22 17:44:57.9918 +0800
Launch Time: 2021-07-22 17:36:19.4760 +0800
OS Version: iPhone OS 12.4.8 (16G201)
Baseband Version: 7.80.04
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Termination Description: SPRINGBOARD, scene-update watchdog transgression: xxxxx exhausted real (wall clock) time allowance of 10.00 seconds | ProcessVisibility: Foreground | ProcessState: Running | WatchdogEvent: scene-update | WatchdogVisibility: Foreground | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 6.300 (user 6.300, system 0.000), 31% CPU", | "Elapsed application CPU time (seconds): 0.000, 0% CPU" | )
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_platform.dylib 0x00000002187ec3f0 os_unfair_lock_lock_with_options$VARIANT$mp + 20
1 libsystem_malloc.dylib 0x00000002187ba454 small_malloc_should_clear + 152
2 libsystem_malloc.dylib 0x00000002187b7c2c szone_malloc_should_clear + 132
3 libsystem_malloc.dylib 0x00000002187c0ca0 malloc_zone_calloc + 140
4 libsystem_malloc.dylib 0x00000002187c1520 calloc + 32
5 libobjc.A.dylib 0x0000000217db562c cache_t::reallocate+ 13868 (unsigned int, unsigned int) + 52
6 libobjc.A.dylib 0x0000000217db5b2c cache_fill + 212
7 libobjc.A.dylib 0x0000000217dc2940 lookUpImpOrForward + 1168
8 libobjc.A.dylib 0x0000000217dcf858 _objc_msgSend_uncached + 56
9 UIFoundation 0x000000022322ff00 +[_UIFontCacheKey fontCacheKeyWithFontName:traits:pointSize:] + 64
10 UIFoundation 0x00000002232b7188 UINewFontIgnoringLinkCheck + 128
11 UIFoundation 0x00000002232259a0 +[UIFont systemFontOfSize:traits:] + 28
12 xxxxx 0x00000001017d848c +[xxxxLoadingWithErrorTipsViewConfig gradientLightConfig] + 19039372 (KSLoadingWithErrorTipsView.m:74)
Post not yet marked as solved
Is there anyway we can set the number of threads used during coreML inference? My model is relatively small and the overhead of launching new threads is too expensive. When using TensorFlow C API, forcing to single thread results in significant decrease in CPU usage. (So far coreML with multiple threads has 3 times the cpu usage compares to TensorFlow with single thread).
Also, wondering if anyone has compared the performance between TensorFlow in C and coreML?
Post not yet marked as solved
I have integration the MetricKit to my project, and had collected the analytics data of MetricKit already, but I'am don't how to convert it to the Chart. Are there some document introduce how to convert the rawData of MetricKit to the chart, such as the power consumption percentage of the app.
The Xcode organization tool could show the MetricKit chart, but it not, but this doesn't tell us how to convert MetricKit's rawData to chart
Post not yet marked as solved
iPhone 12 is adjusted to the minimum in WeChat and the font in the settings is also adjusted to the smallest, it is as big as the standard font of iPhone 11. Why is the gap between the 6.1-inch screen fonts so large? It looks really uncomfortable and affects the user experience.
Post not yet marked as solved
Hi,
All my LazyVStacks flicker when scrolling them fast.
I tried to set a fixed height for the children's views but with no luck.
Is there a solution for that?
Post not yet marked as solved
After installing iOS 15, my iPhone battery has been just straight up worse. I am able to get only a minute of screen on time with every 1% of battery consumed.
Moreover my phone is plagued with other bugs and random shut down.
Post not yet marked as solved
Hi, i have updated iOS from 14.8 to 15. After that i am facing issues like so many apps are lagging. Those were working perfectly fine on the same day prior to update. IPhone storage is taking 3+ mins to load completely. Apple store is taking couple of secs to load. Iphone is getting extremely heat while using. Charging is also taking longer time.
Chat with apple support team, as per their suggestion, updated iOS again using my pc. Still getting the same issue. They are also suggesting to do factory reset as well.
Why would i do factory reset and restore again. Just downgrade it to iOS 14.8 again.
Post not yet marked as solved
I'm using Xcode 13.0 (13A233). I want to access the "enablePerformanceTestsDiagnostics" feature. When I enter "xcodebuild test -project PerformanceTest.xcodeproj -scheme PerformanceTest -destination "platform=iOS Simulator,id=D43B8013-11A6-4E66-A42A-7174B9109276" -enablePerformanceTestsDiagnostics YES" command in the terminal,the xcresult did not produce the memgraphset.zip file for me. I don't know why this happened, Any one can confirm if this is a bug or give me some hints about my operation.
Post not yet marked as solved
Hi,
I am developing a simple passthrough proxy system extension using NETransparentProxyProvider. This is what the extension fundamentally does:
In handleNewFlow open a connection to the remote endpoint using CreateTCPConnection method in Tunnel provider.
Once the remote endpoint is connected open the NEAppProxyTCPFlow and start both ends of the flow.
When I use perf to test the network speed while sending I see a 10 times drop in speed when using my system extension.
iperf -c <server_address>
iperf uses 131072 byte blocks to send data by default for 10 seconds
My code for inbound and outbound flows is quite simple:
For inbound flow read from the remote connection, in the completion handler for read write to the flow and in the completion handler for flow start another read from remote.
For outbound flow read from the flow, in the completion handler write to the remote and in the completion handler for writing to the remote trigger another read from the flow.
Is there any problem with the above approach which can cause network transfer slowdown?
I also captured Wireshark traces for cases with and without my system extension and I see a pattern there.
When I read from the flow the system extension reads chunks of varying sizes irrespective of what the application is sending. Eg. I see 4096, 16384, 8192. When I send these chunks to the remote connection it keeps waiting for ACKs for each chunk irrespective of the TCP window size. I also see a [PSH, ACK] in the last packet for each chunk.
Without my system extension, iperf sends many packets in short time without [PSH,ACK] as it is using bigger buffer and does not wait for ACKs so frequently. It respects the TCP window size.
I can provide any details needed to help root cause this problem. I am testing this on macOS BigSur 11.5.1
Any help is greatly appreciated
Regards