Post not yet marked as solved
Hello,
I'm attempting to automate some performance tests we currently do manually using signposts and Instruments.
It looks like XCTOSSignpostMetric is the perfect tool for the job, but I can't get it to play nicely. If I use the pre-defined signpost metric constants (customNavigationTransitionMetric, scrollDecelerationMetric, etc), it works fine. If I use a custom signpost using the
XCTOSSignpostMetric.init(subsystem: category: name:)
initializer, nothing happens.
The documentation is very sparse on this topic and Googling, Binging, Githubing and Twittering have come up empty.
I reduced the issue to the smallest example I could ( https://github.com/tspike/SignpostTest ).
What am I doing wrong?
Thanks,
Tres
Environment details:
macOS 11.6
Xcode 12.5.1
iOS 14.6
iPhone SE 1st Gen
In the app:
...
let signpostLog = OSLog(subsystem: "com.tspike.signpost", category: "signpost")
let signpostName: StaticString = "SignpostTest"
@main
struct SignpostTestApp: App {
init() {
os_signpost(.begin, log: signpostLog, name: signpostName)
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500), execute: {
os_signpost(.end, log: signpostLog, name: signpostName)
})
}
...
}
In the test
func testSignposts() throws {
let app = XCUIApplication()
// No performance data
let metric = XCTOSSignpostMetric.init(subsystem: "com.tspike.signpost",
category: "signpost",
name: "SignpostTest")
// Works as expected
// let metric = XCTOSSignpostMetric.applicationLaunch
let options = XCTMeasureOptions()
options.iterationCount = 1
measure(metrics: [metric], options: options, block: {
app.launch()
})
}
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
The user reports one issue about my application does not responding.
When he right clicks my application icon on Mac dock, it shows "Applicaiton not responding" , but when he click on the buttons, input box or switch windows of my application UI, it works well, which mean my application is not really stuck.
Does anyone ever see such "FAKE" not responding issue happen ? and what's the reason?
He is on MacOS 12.4.0
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
On an iMac Retina 5K, 27-inch, the render time is ridiculously slow and unresponsive.
It's not the graph, even though data arrives 3 times per second with 920 data points. I've tested this in standalone code - and its fast.
The text and buttons need to be updated at a similar speed.
Although this may appear to be working, it's far from being responsive. In fact, it's only possible to quit the program with a Command-Q, and displaying a basic About box takes forever.
I think my Views are well structured, with most modifiers factored out, so should I conclude that SwiftUI is not suitable for anything beyond a simple REST app running on IOS? I hope not. If Apple were writing something similar, how would they go about it?
I've spent over a year developing this app - wishing and expecting for Apple to come up with something better that doesn't run the entire UI on one single thread, and perhaps able to execute sub-views concurrently as one would expect.
I don't wish to sound critical. I just want to know how to get this UI rendering faster, so I'm crying out for help and advise.
Post not yet marked as solved
hi,
I'm developing a app that uses metal to compute some calculations and to improve the efficiency of the render process i started watching indirect command buffers but there isn't a example that explains the best way to processed.
Any one can provide some tips?
Post not yet marked as solved
Hi, what is the best way to handle dark mode for third party web content in WKWebView?
Post not yet marked as solved
Last time I checked, it was not, so I wonder if that has changed. In the WWDC "Track down hangs with Xcode and on-device detection" was only mentioned about iOS...
Post not yet marked as solved
I have a maxed out 2018 MBP with an i9 and 32GB of ram. On Catalina, I was constantly running 2 Linux VMs, had 3-4 separate Chrome user sessions running with 10+ tabs each, giant MS Excel documents open, XCode w/ 2 apps running simultaneously, iOS Simulator, 1-2 instances of Node, MS Teams, Slack, WhatsApp, PostMan, and barely ever experienced any kind of lag or performance issues. Activity monitor would max out all the time, but then it would use SWAP and my user experience was always great. If I noticed a slowdown, all I had to do was close 1 browser window, and I'd be back to full speed.
After upgrading to Monterey, I keep all my VMs shutdown, any MS application closed, never run more than 1 node instance, and still, I can barely type into this text box without experiencing lag... Application switching takes FOREVER, both via alt-tab, and selecting the application from the dock. Looking at my Activity Monitor, I'm barely using any resources, and somehow, EVERYTHING IS STILL LAGGING!
I am already well aware that Apple purposely curbs their OS performance on "older" hardware, and that this OS is meant to make the M1 chip look better than the Intel chips, but this is a $4,000 laptop, and you've basically turned it into a giant paperweight!
As a comparison, I have a 10 year old MBP with an i7, where the OS has not been upgraded, and it runs 1000x better than my i9 on Monterey.
Does anyone know of any terminal commands I can run to speed things up, or did Apple basically hardcode this OS to lag for non-ARM chipsets?
Post not yet marked as solved
Hi,
This topic is about Workgroups.
I create child processes and I'd like to communicate a os_workgroup_t to my child process so they can join the work group as well.
As far as I understand, the os_workgroup_t value is local to the process.
I've found that one can use os_workgroup_copy_port() and os_workgroup_create_with_port(), but I'm not familiar at all with ports and I wonder what would be the minimal effort to achieve that.
Thank you very much!
Alex
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
Starting from Xcode 12.4 (I think), failing unit tests in framework targets take about 5 seconds to complete. Successful tests complete almost instantly (as expected).
For example, the following test:
func testExampleFailure() {
XCTFail()
}
Takes 4.356 seconds to execute on my 2019 MacBook Pro:
Test Case '-[FrameworkTests.FrameworkTests testExampleFailure]' failed (4.356 seconds).
This seems to only affect unit tests in Framework targets (unit tests for App targets are unaffected). I have also tested this in fresh Framework template projects across multiple Macs, so it appears to be an Xcode bug.
I'd hoped Xcode 13 would fix this issue, but it persists for me on Monterey. Perhaps someone could suggest a workaround?
Post not yet marked as solved
Hello!
I noticed that scrolling through the sidebar (thumbnails view) while reading a PDF document in Preview app is laggy and spikes the CPU.
The document is about 20MB and has ca 2000 pages. I'm using MacOS 12.3.1 on Apple Silicon and Preview v11.0.
I assume that rendering a PDF document and scrolling aren't hard tasks so this bad performance is unexpected. Is it possible to get a solution for that issue? Thanks in advance
Post not yet marked as solved
For me who just switched from android to iphone (iphone11-ios14.4.2), I feel very strange about the animation performance of ios in e-sports games (MOBA), although the animation of ios is very good and very smooth, but I found that In the case of "slightly hot mobile phone", it often happens that the operation does not follow the hand when playing games, that is, under high-speed and frequent finger operations, some operations will always fail or be lost. Pay attention to the game animation at this time. Played strangely slow. [Remarks: There is a character (Luna) in the game of King of Glory that has very high requirements on the operation speed of the fingers. The performance when using this character is demonstrated in the link (bilibili.com/video/BV1Ct411A7X9)], the fingers need to slide very frequently and at high speed .
My doubt is when comparing with Android phones. When using the Luna character of the above game, the above situation will always happen under the high speed combo. In MOBA games, even if the operation fails for a moment, you may lose the whole game. This made me feel very frustrated after buying the iPhone 11, because according to the performance of the A13 processor, this should not happen, and it should completely surpass Android's Snapdragon processor. But in fact, a similar situation will never happen in android. As long as the operation is pressed by the player, it will definitely be triggered. Although the animation of android may drop frames or freeze, the operation will never fail and lost. Under ios, the animation will never be stuck, but it will be played slowly, but the finger operation will always fail in extreme cases, that is, there is no response when you press it.
This has led to iPhones always missing opportunities on the battlefield when playing MOBA games. I suspect that this is related to some optimizations of the ios system, and I hope that the developers of ios can help to solve the confusion. And whether it is possible to add relevant options in the system settings to turn off this optimization, so that when using specific games that require high fingers, ios can respond quickly to finger operations like android?
Post not yet marked as solved
When scrolling a collection view, it looks like all supplementary views (even those that currently not appear) are invalidated. If there is a large number of supplementary views (section headers in my case) this significantly affects scrolling performance.
Can I instruct the collection view to invalidate only the visible supplementary header views (rather than all of them) when user scrolls the view?
Here is the code I use to create the collection view (tableview-like layout) in my custom UICollectionViewController class:
// Create list layout configuration
UICollectionLayoutListConfiguration *config = [[UICollectionLayoutListConfiguration alloc] initWithAppearance:UICollectionLayoutListAppearancePlain];
config.headerMode = UICollectionLayoutListHeaderModeSupplementary;
// Create compositional layout based on configuration and assign to collection view
UICollectionViewCompositionalLayout *layout = [UICollectionViewCompositionalLayout layoutWithListConfiguration:config];
self.collectionView.collectionViewLayout = layout;
Post not yet marked as solved
Hello,
I'm investigating a crash where keyWindow is nil when I don't expect it to be nil.
I would like to understand when this can happen. Indeed,I could make a fix by guarding for nil values, but this would lead to an invalid state.
Context
We want to return quickly from application(didFinishLaunchingWithOptions:), so:
We set a view controller as a splash screen rootViewController => we mark the window with makeKeyAndVisible().
We queue initializations asynchronously on the main queue.
=> Basically, while the app is initializing starting, we're displaying a splash screen view controller.
When the app is done initializing, it needs to present the actual UI. A last asynchronous task on the main queue does this. We get keyWindow from UIApplication to set the new view controller with the actual UI. That's where we assume that it shouldn't be nil and force-unwrap it, but alas, in some instances it's nil.
Misc
This crash only happens when app built with Xcode 13.x, running on iOS 15.
I cannot reproduce this bug, and it has fairly little occurrence. (100s over 100000 of sessions)
I also attached a sample crash
Questions
Given that I made the window "key and visible" in step 1, what could cause the window to stop becoming "key".
What would be the correct way to get the window to set the new root view controller ?
I don't really want to guard against a nil value because then it means that I wouldn't be able to set my new rootViewController and the app would be stuck on the launch screen.
2021-12-01_18-16-29.7629_-0700-9b5855582b13262f154acae64dd3140ad49c84f3.crash
Thanks a lot!
Bruno
I'm trying to hint the task scheduler that some threads should be scheduled together using the task_policy_set API with THREAD_AFFINITY_POLICY (in lieu of there being no "real" thread to core affinity API).
All the examples mention setting the policy after creation but before execution of the task(s). Unfortunately, I'm not creating these tasks (but OpenMP is), and when I then try to use the API on an already running thread, I get a return value of KERN_INVALID_ARGUMENT(= 4)
thread_affinity_policy_data_t policy = { 1 };
auto r = thread_policy_set(mach_task_self(), THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, THREAD_AFFINITY_POLICY_COUNT);
When I replace mach_task_self() by pthread_mach_thread_np(pthread_self()), I get an KERN_NOT_SUPPORTED error instead (= 46, "Empty thread activation (No thread linked to it)").
Has anyone used these APIs successfully on an already running thread?
Background:
The code I'm working on divides a problem set into a small number of roughly equal sized pieces (e.g. 8 or 16, this is an input parameter derived from the number of cores to be utilized). These pieces are not entirely independent but need to be processed in lock-step (as occasionally data from neighboring pieces is accessed).
Sometimes when a neighboring piece isn't ready yet for a fairly long time, we call std::this_thread::yield() which unfortunately seems to indicate to the scheduler that this thread should move to the efficiency cores (which then wreaks havoc with the assumption of each computation over a piece roughly requiring the same amount of time so all threads can remain in lock-step). :(
A similar (?) problem seems to happen with OpenMP barriers, which have terrible performance on the M1 Ultra at least unless KMP_USE_YIELD=0 is used (for the OpenMP run-time from LLVM). Can this automatic migration (note: not the relinquishing of the remaining time-slice) be prevented?
Post not yet marked as solved
Scrolling a collection view with a large number of supplementary header views is extremely slow. The more sections, the worst is the scrolling performance. (Tested with 5,000 sections).
Best to give it a try and see for yourself.
Code is available at https://github.com/yoasha/CollectionViewTest
To reproduce, run the demo app with Xcode on either iPhone or iPad simulator (or a real device), select "Collection View" on the main page, and try to scroll.
Any thoughts?
Post not yet marked as solved
When there is a large number of supplementary views, scrolling is extremely slow.
To reproduce:
Download Apple's demo of "Implementing Modern Collection Views" from here
Open project in Xcode and show PinnedSectionHeaderFooterViewController.swift
Go to line 106 and replace it with let sections = Array(0..<3000)
Run project, navigate to "Pinned Section Headers" page, and try scrolling.
Scrolling is barely possible and extremely slow!
While profiling with Time instrument, issue seems to rely in invalidating supplementary views. Screenshot attached below.
How can I fix this? (I have many section headers in my view)