PageSetupDialog crash on Sierra

This code works since REALbasic2011, on the differents Mac OS since 2011… But with Sierra, PageSetupDialog crashes
Xojo 2016 r3

mySetupString is a saved PrinterSetup, possibly made on another Mac/Printer/MacOS

dim aps As PrinterSetup
dim bretPR As Boolean
aps = new PrinterSetup
aps.SetupString = mySetupString
bretPR = aps.PageSetupDialog <-- crash here, mostly when mySetupString was not recorded on this Mac

What can I do ?



The report :

Process: 8print.debug [811]
Path: /Users/USER/Documents/*/
Identifier: 8sens.8print
Version: 8print (
Code Type: X86 (Native)
Parent Process: ??? [1]
Responsible: 8print.debug [811]
User ID: 502

Date/Time: 2016-11-06 19:41:47.034 +0100
OS Version: Mac OS X 10.12.1 (16B2657)
Report Version: 12
Anonymous UUID: CBC8C272-E13A-8207-5987-2A5C0556F815

Time Awake Since Boot: 7000 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue:

Exception Codes: KERN_INVALID_ADDRESS at 0x000000000000008c

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0x8c:
__TEXT 0000000000001000-0000000000eb2000 [ 14.7M] r-x/rwx SM=COW /Users/USER/Documents/*/

Application Specific Information:
Performing @selector(menuItemAction:) from sender NSMenuItem 0x162c780

Thread 0 Crashed:: Dispatch queue:
0 0x936c8717 PJCSessionHasApplicationSetPrinter + 6
1 0x0dca59c2 0xdc8d000 + 100802
2 0x925e6aee -[NSWindowController _windowDidLoad] + 671
3 0x92588e62 -[NSWindowController window] + 115
4 0x92c15d73 -[NSPageLayout runModalWithPrintInfo:] + 179
5 XojoFramework 0x01185c88 0x116a000 + 113800
6 XojoFramework 0x012d2db6 printerSetupPageSetup + 34
7 8print.debug 0x00050fde PrinterSetup.PageSetupDialog%b%oo + 52

Can you check if there is a printer in the settings menu of macOS?
I guess macOS needs at least one configured printer.

Possibly the origin of the error ?

Did you try to save the macOS Sierra Settings, and use that one ?

Thanks Marcel : yes there is a printer in the settings, and Emile : yes if a save the current settings in a SetupString, PageSetupDialog works…
But you gave me an idea, I compared two SetupString, one works and the other not
The only differences (except name and date) are PMHorizontalRes and PMVerticalRes (300 / 72) : is there a problem there ?

We have several customers who updated to Sierra and can’t print. In all of these cases the printer manufacturer has admitted that the driver is incompatible.

Sam, in the case of my examples, it’s Apple only
I think there is a problem while reading the SetupString when it’s recorded with a call having MaxHorizontal/VerticalResolution=-1

setupstring is a string, may be you could intercept the reading of the string, and change the bad value before using it in pagesetup ?

ps: bonjour Marc, cela faisait longtemps ! :wink:

“salut jean-yves” :slight_smile:

but I want to keep the value of 300, she’s not bad !
in the previous versions of RB/Xojo, she was read and processed without problem

You can’t keep the value of 300 if the driver doesn’t support it. Sending the wrong values to a printer can certainly cause issues.

But Greg, it’s new ? Why to crash and not to adapt the settings, like before ?

And in my case, the driver supports 300 dpi, it’s a laser writer : just Xojo/Sierra don’t want to open PageSetupDialog

Didn’t you say that you were loading a setupstring from another computer that had a resolution of 300dpi because you were only getting 72 on this computer?

No, I try to load a setupstring, and according to my tests, but there may be other cases :

  • regardless of the printer and its resolution
  • PageSetupDialog crashes when the setup string includes a resolution of 300dpi
  • only on Sierra

Also having this problem.
Trying to narrow it down.

Hi Greg, Dirk, what can I do ?

I solved this for me.
Just delete the PageSetupString stored with older versions of OS X
Do not load it and try Pagesetup then, it crashes…
In my case i deleted the file on disk and then create a new one using PageSetup, after that all works without further problems.

If you have Christians’s plugins, you can use NSPrintInfoMBS to work around it for now.

I still haven’t completely found what is going wrong, but an invalid setupstring didn’t use to crash the app when calling PageSetupDialog or OpenPrinterDialog prior to Sierra. With Sierra an invalid setupstring will lead to a crash that you can’t catch.

As far as I know there is also no way to test if the setupstring is corrupt. What I do see is that when you look at the PrinterSetup.Setupstring (in the debugger) the length will be completely wrong and the setupstring will not have been loaded completely.
Comparing the printersetup.setupstring to the string you used to set it does not seem to work either though, since it seems to always be different, even when you load a correct setupstring.

As soon as I have a reliable way to cause it, I’ll create a feedback case.

It still should not crash though

Thx Stephan, but you lose the setting “Landscape”, and the MaxHorizontal/VerticalResolution if called with -1

Thats true …

i set this on runtime, so i can’t lossing it