# macOS 64-bit Graphics.NextPage Causes Application to Hang

**URL:** <https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997>\
**Category:** macOS\
**Created:** [April 2, 2017, 8:27pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997 "2017-04-02T20:27:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Crick](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_crick/32/709_2.png) [@Scott\_Crick](https://forum.xojo.com/u/Scott_Crick)\
**Post date:** [April 2, 2017, 8:27pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/1 "2017-04-02T20:27:21Z")

</div>

Feedback Case #47610 - Graphics.NextPage results in the application hanging in Threads in MacOS 64-bit.

When building for macOS 64-bit, using Graphics.NextPage in a Thread will cause the built application to freeze. The application becomes non-responsive and the macOS Dock shows that the Application is Not Responding. It behaves similar to what happens when a built app is in a infinite tight loop.

I included a simple sample project showing the issue with the feedback case.

This works as I would expect when building for 32-bit.

\<[https://xojo.com/issue/47610](https://xojo.com/issue/47610)\>

Has anyone else run into this?

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [April 3, 2017, 3:22am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/2 "2017-04-03T03:22:15Z")

</div>

While I agree that this is a bug, why do you print from a thread?

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [April 3, 2017, 3:01pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/3 "2017-04-03T15:01:53Z")

</div>

> [@324246:@Joe Ranieri](#):
>
> While I agree that this is a bug, why do you print from a thread?

To keep your UI responsive? If you’re printing several hundred pages, a thread would be the only way to do it, right?

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [April 3, 2017, 3:07pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/4 "2017-04-03T15:07:03Z")

</div>

Wouldn’t the OS Print Spooler take the Data and handle it while you can continue your work?

Edit: Restored because @Bob Keeney answered my question 🙂

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [April 3, 2017, 3:09pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/5 "2017-04-03T15:09:47Z")

</div>

Sure, but your app still needs to be responsive. Imagine the worst case and someone trying to print 10,000 pages by accident. The UI would be unresponsive because it takes a while to send that much data to the print spooler and the only way to kill the print would be to kill the app and then cancel the print queue. All doable, but printing from a thread doesn’t seem all that unreasonable.

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [April 3, 2017, 3:24pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/6 "2017-04-03T15:24:52Z")

</div>

> [@324344:@Bob Keeney](#):
>
> the only way to kill the print would be to kill the app and then cancel the print queue.

You are correct. Most users would act this way. But the best way would be to Pause the Spooler and Cancel the Print Job once the App finished sending the Data to the Spooler.

But i do not want to hijack the Thread.  
@Joe Ranieri already said it’s a bug and we have a Feedback Case. Thank you @Bob Keeney 🙂

---

<div class="post-metadata">

**Author:** ![Scott\_Crick](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_crick/32/709_2.png) [@Scott\_Crick](https://forum.xojo.com/u/Scott_Crick)\
**Post date:** [April 3, 2017, 4:38pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/7 "2017-04-03T16:38:13Z")

</div>

> [@324246:@Joe Ranieri](#):
>
> While I agree that this is a bug, why do you print from a thread?

As @Bob Keeney already indicated, I am printing from within a thread to keep the application UI responsive. For this particular application, each page is generated in a thread to a “description” format (an intermediary step that describes the page layout) and then cached. A separate thread watches the cache and, when a new cached page descriptor is available, it takes that description and generates the actual drawing commands to the printer to print the page. If I didn’t have this threaded, the application would be completely unresponsive for long periods of time (print jobs can be 100s of pages long). Plus, there is a progress window that is displayed that shows progress of generating the cache as well as actual pages being sent to the printer. Generating the cache tends to be faster than spooling the pages to the printer, so this is the the best way I could come up with to ensure that printing started right away but didn’t also lock up the UI.

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [April 4, 2017, 1:30am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/8 "2017-04-04T01:30:14Z")

</div>

Just a thought; if you’re rasterizing to a intermediary format, couldn’t you then send that to a helper application, which then prints in the background, keeping your main application free of the actual printing?

---

<div class="post-metadata">

**Author:** ![Scott\_Crick](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_crick/32/709_2.png) [@Scott\_Crick](https://forum.xojo.com/u/Scott_Crick)\
**Post date:** [April 4, 2017, 1:41am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/9 "2017-04-04T01:41:14Z")

</div>

I suppose I could, but I have next to no experience with that sort of setup. I wouldn’t know where to begin. And, I can’t help but think (at least to my inexperienced brain) that this would be added complexity. Maybe I’m wrong there and this would be a simpler solution?

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [April 4, 2017, 6:22am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/10 "2017-04-04T06:22:36Z")

</div>

Of course, you can wait the next 2-3 years (just kidding) until the bug is fixed.

Welcome to the new world of helper apps. Of course, this is added complexity. But sometimes it’s the only solution. You mainly need 2 things:

- The 2 apps need to communicate. IPC, TCP, even AppleScript. For one app of mine a simple AppleEvent does the job. For another I use xml with TCP. For yet another I will be using a combination of TCP and shared memory (MBS plugin!).
- You need to manage your build process. The second app needs to be in a special place in the main app. You need to sign the helper, too, of course. It’s now even possible to build both apps at once.

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [April 4, 2017, 6:49am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/11 "2017-04-04T06:49:12Z")

</div>

> [@324402:@Scott Crick](#):
>
> I suppose I could, but I have next to no experience with that sort of setup. I wouldn’t know where to begin. And, I can’t help but think (at least to my inexperienced brain) that this would be added complexity. Maybe I’m wrong there and this would be a simpler solution?

In the simplest form, you write out your immediately data to a single file, then you call your helper application passing it that file, it opens, reads the file, processes and print it, then quits.

Obviously there’s a bit more fleshing out you need to do, but in principle it’s not scarily complicated.[quote=324413:@Beatrix Willius]The 2 apps need to communicate. IPC, TCP, even AppleScript. For one app of mine a simple AppleEvent does the job. For another I use xml with TCP. For yet another I will be using a combination of TCP and shared memory (MBS plugin!).[/quote]  
You can also use ICP sockets to communicate.

For Scott’s project, I only see the need for one way communication, unless I’m mistaken so he could save some effort here.

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://forum.xojo.com/user_avatar/forum.xojo.com/david_cox/32/227_2.png) [@David\_Cox](https://forum.xojo.com/u/David_Cox)\
**Post date:** [April 4, 2017, 8:05am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/12 "2017-04-04T08:05:14Z")

</div>

I let them both communicate (instructions and progress) via a shared SQLite database.

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [April 4, 2017, 3:44pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/13 "2017-04-04T15:44:47Z")

</div>

> [@324401:@Sam Rowlands](#):
>
> Just a thought; if you’re rasterizing to a intermediary format, couldn’t you then send that to a helper application, which then prints in the background, keeping your main application free of the actual printing?

I would wait for the bug to be fixed instead of going through such hoops to work around it. Or, for now, just draw from the main thread.

---

<div class="post-metadata">

**Author:** ![Scott\_Crick](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_crick/32/709_2.png) [@Scott\_Crick](https://forum.xojo.com/u/Scott_Crick)\
**Post date:** [January 21, 2018, 11:34pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/14 "2018-01-21T23:34:26Z")

</div>

Ten months later and this is still a problem. I’m, frankly, surprised that this is still the case. Looking in Feedback and it looks like my original bug report was verified on April 4th, 2017. But we’re now on Xojo 2017r3 and this exact same behavior is still occurring. Am I the only one that is seeing this? Am I the only one printing from a thread?

I haven’t been beating the drum about this over the last several months because my focuses have been elsewhere, but with Apple’s 64-bit deadline fast approaching, my focus has returned to updating this application to 64-bit and I need to find a solution to this. Unfortunately, a helper application is not an ideal solution in this case and adds what I say as needless complexity for this particular application.

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [January 21, 2018, 11:45pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/15 "2018-01-21T23:45:17Z")

</div>

> [@324413:@Beatrix Willius](#):
>
> Of course, you can wait the next 2-3 years (just kidding) until the bug is fixed…

perhaps (just kidding) was an overstatement 🙂

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [January 22, 2018, 6:02am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/16 "2018-01-22T06:02:53Z")

</div>

What alternatives do you have:

- Develop the “unnecessary complex” feature of a helper app
- Pray to Chtuluh (spelling?)
- Use a different method of printing where you don’t use Graphics.next page. For instance I have html which I convert to pdf
- Be a dead fish in the water when 10.14 comes around

Helper apps aren’t that complicated. I’m not working on my third one. You need to study the IPC example, which is one method. Then you need to define your communication. Debugging is annoying, but I simply start both apps in the debugger.

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [January 22, 2018, 7:06am UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/17 "2018-01-22T07:06:32Z")

</div>

Helper apps is one of those features that seem overly complex and a bit scary until you try it.

I used to feel like this about Extends, Graphics, Databases, Threads, AddHandler, Delegates etc

Truth is: nothing much to it.

And helper apps allow you to use more than one processor core - that alone is worth the price of admission 😉

---

<div class="post-metadata">

**Author:** ![Scott\_Crick](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_crick/32/709_2.png) [@Scott\_Crick](https://forum.xojo.com/u/Scott_Crick)\
**Post date:** [January 22, 2018, 1:58pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/18 "2018-01-22T13:58:22Z")

</div>

It’s not that I don’t understand the point you all are making about a helper app. Granted, I haven’t gone down that route and would need to research to understand how to make it work, but I’m sure it could be done and, perhaps, it is easy to do.

My point is, I shouldn’t have to. It does add unnecessary complexity to my application. I have a solution right now that works perfectly when compiled for 32-bit. This application is a very simple application. But, printing occurs within a loop and it is of key importance that the UI remains responsive during printing. I can put in the work to learn and implement a helper app to handle printing (and I probably will go ahead and learn because I can see situations where it would be beneficial). But, for this application, it adds complexitycomplexity I see as unnecessary because it’s already working, except for having to compile for 64-bit reveals an issue that Xojo has already verified is a bug.

I’m not saying that Xojo needs to drop everything and immediately rectify my situation. And, heck, it’s entirely possible this is not a simple fix and would require some sort of large-scale refactoring and that’s why it’s not yet been addressed. I’m just saying that I’m surprised no-one else is running into this. Does everyone else handle any and all printing via a helper application? Is that really the one true way of doing this?

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [January 22, 2018, 2:39pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/19 "2018-01-22T14:39:57Z")

</div>

You are arguing in circles. Sure, you shouldn’t have to add the complexity. Sure, it may be an easy fix for Xojo. Do you need a 64bit app or can you wait until Xojo fixes this? That is the question you have to answer.

At the moment I’m having a go again at my helper app for getting AppleScript data out of mail. If Apple would fix the speed issue I also wouldn’t have to fiddle around with this. I don’t understand why AppleScript is so slow for High Sierra. But very likely they will fix this way after Xojo fixes your bug.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:43pm UTC](https://forum.xojo.com/t/macos-64-bit-graphics-nextpage-causes-application-to-hang/36997/20 "2020-10-29T18:43:00Z")

</div>


