Re: FYI: info on our scary Mac rebooting iOS testing crash.

2019-10-18 Thread Alex Zavatone via Cocoa-dev
Wow was this ever fun.

Woo hoo!

Let this be an exercise in the dangers of memory leaks.

Our team uses VIPER with everything being strongly linked. Also in Objective-C, 
there are cases where private instance variables are used, not the wrapping 
properties, not to mention strongly referenced delegates. Who needs memory 
management, right? Well, guess what? When you do this, it's really easy to leak 
lots of objects and this means lots of mach ports are requested from Xcode and 
this means that there are lots of mach ports requested by the WindowServer and 
this means that the GPU driver, (SkyLight) requests more mach ports - until the 
system says, "no, you can not have any more.”  That happens around 260,000+ 
mach ports in the WindowServer. This restarts the GPU. And when the GPU 
restarts, the system either restarts the Mac or crashes the user session out to 
the login screen.

After a night fixing memory bugs until midnight, I ran our 280 KIF tests and no 
more than 20,000 mach ports were requested. And the full test ran all the way 
through without rebooting the Mac or crashing out to the login screen.  

Memory leaks matter!

Oh, and if anyone wants video of watching the Mac reboot when the WindowServer 
has over 260,000 mach ports allocated, I'll happily post a link.

Cheers,

Alex Zavatone

> On Oct 17, 2019, at 12:07 PM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> As a background, I mentioned that we occasionally have these scary crashes 
> while running our iOS tests that either reboot your Mac or crash the user 
> process out to the login screen.
> 
> Yesterday, I noticed that I could not run our tests at all without crashing 
> around a certain area and on 3 different Macs, all with 24 GB or more of RAM.
> 
> My speculation that it, might be related to mach ports was entirely correct 
> as after 8 crashes, some debug logs finally appeared - but not all the time.
> 
> Our iOS UI tests are run by KIF which uses XCTest as its foundation.  When 
> running these 280+ UI automation scripts in the Simulator, the amount of 
> ports used by Xcode increased rapidly as the tests ran for 30 mins and the 
> WindowServer process appeared to have about 20,000 more Mach ports allocated 
> than Xcode over that time.  
> 
> Right before the crash happened, the WindowServer had allocated over 256,000 
> ports and Xcode was just behind by a few thousand.  Then, all operation 
> pauses for a few seconds, the displays go black, and a few seconds later, the 
> user login screen appears as the previous user session crashed out.  
> 
> What happened is that Xcode asked for more ports and asked the WindowServer 
> to allocate more ports and the WindowServer asked the GPU driver for more 
> ports and thread com.apple.SkyLight.mtl_submit to crash with either a SIGSEV 
> or SIGILL.  Either the WindowServer or the Skylight framework for MetalDevice 
> and caused a GPU restart.  The OS then crashed the user session out to the 
> login screen.
> 
> Now, the question.  Why the hell is XCTest causing Xcode to request so many 
> Mach ports and never release them until the app is quit or the system crashes?
> 
> I tested this last night outside of our app with XCTest and KIF simply going 
> back and forth between two screens in an iOS app several thousand times In 
> the Simulator. The mach ports of both Xcode and the WindowServer go up and 
> are not released until the app quits, but not nearly as fast as in our tests. 
>  
> Is this a mach port leak in XCTest?  
> 
> Does anyone know the details on the guts of this?
> 
> Thanks a lot and I hope this helps someone else. 
> 
> Alex Zavatone
> 
> Sent from my iThing.
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Not seeing rightMouseDown: - what are the docs actually saying ?

2019-10-18 Thread Aandi Inston via Cocoa-dev
I believe I may be seeing an effect described in the Cocoa docs for the
rightMouseDown:
method. I am unsure exactly what the docs are saying however. Symptom:
compiled for
64-bits, an unhandled rightMouseDown: is eventually sent to the NSWindow
subclass,
but compiled for 32-bits (and run on 10.11.6 at least) the event never
arrives.

For NSView, we see "In macOS 10.7 and later, if the event is not handled,
this method
passes it up the responder chain." For NSResponder we see "Prior to OS X
v10.7, NSView
did not pass unhandled rightMouseDown: events up the responder chain. In
macOS 10.7 and
later, NSView passes rightMouseDown: events up the responder chain if
AppKit doesn’t
find an associated context menu to display for the view. To avoid binary
compatibility
issues, this new behavior is enabled only for applications linked on macOS
10.7 or
later."

But what is the actual test for whether to do this? "Running on" and
"linked on" are
both 10.11. Is it actually looking at the "Deployment target"? To make
matters worse,
my code is running as a plug-in and I'm going to take a guess that if a
deployment
target applies, it is the one selected in the main executable (not under my
control)
rather than the plug-in... can anyone explain what Cocoa would be looking
at?

And if it turns out that I'm not going to get rightMouseDown: sent directly
to my
NSWindow, is there any alternative to subclassing any NSView or descendent
(including
NSControls of various flavours) that might be the initial responder?

Thanks in advance!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


On Demand Resource Trouble in Xcode 11 / iOS 13

2019-10-18 Thread Steve Mykytyn via Cocoa-dev
I'm having a problem with ODR in Xcode 11. Worked fine in Xcode 10 / iOS
12, both device and simulator.

1. I have the asset catalog in the main bundle
2. I have the Build Setting set to YES for Embed Asset Packs in Product
Bundle
3. I can see that the assets are correctly copied into the bundle.
4. The Appearances of each image is set to None
5. There are no spelling errors in the asset tags
6. Using the old build system
7. The production app on the App Store works fine on iOS 12, fails on iOS
13.

I get varying results depending on the tag and the simulator / device.

On a real iPhone 11 Pro, the method returns the tag not found error message:

Error Domain=NSCocoaErrorDomain Code=4994 "The requested application data
doesn’t exist." UserInfo={NSLocalizedFailureReason=InvalidTag}

On an iPhone 11 Pro simulator, it finds the tagged resources, but trying to
retrieve the images results in nil.

Same failures on a simulated older device / OS (6s/11.0), which worked fine
in the past.

I've tried providing images for light, dark, etc.  No luck.

Any suggestions?  At this point I'm getting ready to just avoid on demand
resources entirely...
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com