More on 10.12/10.13 crashes

I’ve just received a bit more log info from a user where we are witnessing the CoreGraphics crash:

Jan 26 10:42:16 Henks-Mac-Pro BRU PE[664]: BRU PE(664,0xa9b361c0) malloc: *** mach_vm_map(size=1048576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Jan 26 10:42:17 Henks-Mac-Pro BRU PE[664]: assertion failed: 17D47: libxpc.dylib + 41236 [CD44097B-4B65-3F75-AB7F-52228229FFB5]: 0x3 Jan 26 10:42:18 --- last message repeated 10 times --- Jan 26 10:42:18 Henks-Mac-Pro BRU PE[664]: BRU PE(664,0xb071e000) malloc: *** mach_vm_map(size=1048576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Jan 26 10:42:18 Henks-Mac-Pro com.apple.xpc.launchd[1] (com.tolisgroup.bru-pe.16416[664]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
Since we don’t call libxpc from within our code, this must either be a Xojo or MBS plugin call.

@Christian Schmitz - could this be part of the Icon handling in MBS?

Anyone have an idea?

“can’t allocate region”. It’s running out of memory.

I understand that, but the crash is occurring while manipulating icons and I use the MBS iconfamily stuff for that.

I also don’t use any difert memory allocation within my code. Any mallocs occurring are either occuring within Xojo’s Framework or the MBS plugin parts.

64bit?
There are still hard-to-track graphics crashes on MacOS
Any chance that the images being handled do not have a width divisible by 4, for example?

Already went there, but this is a 32bit compile. I do have some 22x22 images and I ask for 22x22 icons from the MBS IconMBS calls (for the Listbox rows).

Maybe I’ll try dropping those to 16x16 or go up to 24x24.

Are you using IconImageMBS( size) ?
I cannot recall why now, but I have a documented code change where I chose to stop using that myself in 2014

[quote=371023:@Jeff Tullin]Are you using IconImageMBS( size) ?
I cannot recall why now, but I have a documented code change where I chose to stop using that myself in 2014[/quote]
Yes - that’s exactly what I’m using. I used the MacOSLib icon stuff for a while, but MBS gives me both Windows and Mac OS in one call.

Taking this further, I narrowed down my code and the displayed element that I believe to be the cause:

Self.cvFile.Backdrop = SWorkspaceMBS.iconForfileType(extension(Self.st_CurrentFileNameText)).CopyPictureWithMask

And the resulting image on 10.13 looks like this (when it doesn’t crash):

IIt’s totally clean on 10.11 and earlier (I don’t have a 10.12 system at the moment).

I see the same result if I change the code to use:

Dim i as New IconMBS("", "", extension(Self.st_CurrentFileNameText), "") Self.cvFile.Backdrop = i.IconFamily.Icon(32)

I’ve also swapped out 3 different versions of MBS including the latest version (18.0) With the same result.

@Christian Schmitz ?

Here’s the output from same compiled code under 10.11.6:

This is the code that I use for showing icons for files:

[code]Private Function getFileIcon(size as integer, extension as string) as Picture

'get file icon for extension

if extension = “” then Return nil

dim ScaleFactor as Integer = self.BackingScaleFactorMBS

dim theIcon as IconMBS = new IconMBS("", “”, extension, “”)
dim pic as new Picture(size * ScaleFactor, size * ScaleFactor)
dim thePictureContext as CGBitmapContextMBS = CGBitmapContextMBS.CreateWithPicture(pic)
const DrawNormal = 0
const DrawNoImage = 2
const DrawNoMask = 4
const DrawSelected = &h8000
if theIcon = nil or thePictureContext = nil then
Return nil
end if
thePictureContext.ClearRect CGRectMBS.Make(0, 0, size * ScaleFactor, size * ScaleFactor)
theIcon.DrawIconCGContext(thePictureContext.Handle, 0, 0, size * ScaleFactor, size * ScaleFactor, 0, 0, DrawNormal, &c000000)
thePictureContext.Flush
Return pic

End Function[/code]

Curious since that’s what the IconFamilyMBS extension to FolderItem is “supposed” to do automatically.

I’ll swap that out for your method and see if the result is cleaner and no longer crashes.

Thanks, Trixie, that sorted the drawing glitch under 10.13. Now I’ll run tests for the crash. :slight_smile:

I’m going to have to test all of this Monday morning. Thanks for digging into the crashes and soloing out the problem, Tim. I’m currently using FolderItem.IconMBS(width as Integer, WindowsFlags) as Picture to get a picture of the file icon. Super fun…

So far, 8 tests that had been crashing with the CoreGraphihcs traceback seem to be sorted - BUT … I’m not sure if that’s due to changing to Trixie’s method, or of making sure all of my icon requests were multiple of 4 in size.

Multiple of 4 was the only cure for several of my MBS-related issues.

Well, it’s quite possible Apple broke the old icon APIs.

FolderItem.IconMBS function now prefers going with NSWorkspaceMBS.IconForFile.

That’s what I was originally using -

Self.cvFile.Backdrop = NSWorkspaceMBS.iconForfileType(extension(Self.st_CurrentFileNameText)).CopyPictureWithMask

That still provided the corrupted image shown above. Using Trixie’s solution has resolved it on 10.12 / 10.13.

So, between adding the Terminate declare to App.CancelClose, Shifting to images that are multiples of 4 in w*h, and moving to Trixie’s method for drawing the icons, I’m in a pretty good place today with regard to 10.13.

Hopefully, these notes can help others.