Skip to content

quartz hanging

9 messages · rsparapa at mcw.edu, biii+rsigm@c m@iii@g oii 8p@wexpress@com, Stefan Evert +2 more

#
Okay, it took me a while, but I now have a very small reprex for quartz 
(not xquartz) failing. I cannot repro this on linux with R-4.4.3 and the 
same package versions.

This is using emacs/ess, though it behaves the same on the console. I do 
not have RStudio installed.

|R.version # _ # platform aarch64-apple-darwin20 # arch aarch64 # os 
darwin20 # system aarch64, darwin20 # status # major 4 # minor 4.3 # 
year 2025 # month 02 # day 28 # svn rev 87843 # language R # 
version.string R version 4.4.3 (2025-02-28) # nickname Trophy Case 
Sys.info()[c("release","version")] # release # "24.5.0" # version # 
"Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; 
root:xnu-11417.121.6~2/RELEASE_ARM64_T6041" plot(1:10) |

(This can also be reproduced using |ggplot(mtcars, aes(mpg, disp)) + 
geom_point()|.)

At this point, change to the quartz window, it looks fine. Press |cmd-p| 
and a print dialog comes up, normal. Escape out. Press |cmd-p| again, 
and a bunch of rows dump all at once:

|2025-07-03 22:12:31.320 R[85631:98913917] The behavior of the 
UICollectionViewFlowLayout is not defined because: 2025-07-03 
22:12:31.320 R[85631:98913917] the item width must be less than the 
width of the UICollectionView minus the section insets left and right 
values, minus the content insets left and right values. 2025-07-03 
22:12:31.320 R[85631:98913917] The relevant UICollectionViewFlowLayout 
instance is <NSCollectionViewFlowLayout: 0x15b623740>, and it is 
attached to <NSCollectionView: 0x15b623000>. 2025-07-03 22:12:31.320 
R[85631:98913917] Make a symbolic breakpoint at 
UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the 
debugger. 2025-07-03 22:12:31.322 R[85631:98913917] The behavior of the 
UICollectionViewFlowLayout is not defined because: 2025-07-03 
22:12:31.322 R[85631:98913917] the item width must be less than the 
width of the UICollectionView minus the section insets left and right 
values, minus the content insets left and right values. 2025-07-03 
22:12:31.322 R[85631:98913917] The relevant UICollectionViewFlowLayout 
instance is <NSCollectionViewFlowLayout: 0x15b623740>, and it is 
attached to <NSCollectionView: 0x15b623000>. 2025-07-03 22:12:31.322 
R[85631:98913917] Make a symbolic breakpoint at 
UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the 
debugger. 2025-07-03 22:12:31.324 R[85631:98913917] The behavior of the 
UICollectionViewFlowLayout is not defined because: 2025-07-03 
22:12:31.324 R[85631:98913917] the item width must be less than the 
width of the UICollectionView minus the section insets left and right 
values, minus the content insets left and right values. 2025-07-03 
22:12:31.324 R[85631:98913917] The relevant UICollectionViewFlowLayout 
instance is <NSCollectionViewFlowLayout: 0x15b623740>, and it is 
attached to <NSCollectionView: 0x15b623000>. 2025-07-03 22:12:31.324 
R[85631:98913917] Make a symbolic breakpoint at 
UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the 
debugger. |

(Repeating the |cmd-p| for the above messages is not required, it?s just 
an oh-by-the-way. Not sure why it?s complaining, and I don?t entirely 
understand what the messages are really saying. But since it?s neither a 
warning nor a device-breaking error, I have been ignoring them.)

Now, load |kableExtra|. I haven?t tried many other packages, so far it 
is just this one package.

|library(kableExtra) |

That?s all, no more code/expressions/evaluation required. Back to the 
quartz window and press again |cmd-p|, and on the R console one of these 
errors appears. I say ?one of? because it varies slightly based on base 
graphics or ggplot2, or CRAN-vs-P3M ggplot2. Since the message-component 
is the same, I believe it to be the same underlying problem.

|### with base graphics alone, I see this: Error in 
getNamespace("grDevices") : Start tag expected, '<' not found [4] ### 
using ggplot2 from P3M, this is the only message I see Error in 
diff.default(xscale) : Start tag expected, '<' not found [4] ### using 
ggplot2 from CRAN, I see the p3m-error above or one of these two Error 
in length(x) : Start tag expected, '<' not found [4] Error in is.unit(y) 
: Start tag expected, '<' not found [4] |

The quartz window for that R process is now unresponsive, R will plot 
nothing more, and R will not open a new quartz window. I can |dev.off() 
; dev.list()| and it suggests there are no windows, but the window is 
still present and unresponsive. |dev.new()| does nothing. Additional 
plot expressions (base or grid) do nothing, no error or warning, no 
rendering.

Interestingly, when I do this with base graphics, the print dialog 
remains up and is now unresponsive. (Does it matter that it says ?no 
printer found??) When I repro this using |ggplot2|, the print dialog 
does go away when the error hits, suggesting it is slightly later in 
code execution?

Variations attempted:

  * R is just the default R installer, I have not compiled it or any of
    its components manually;
  * base graphics vs |ggplot2| grid, barely-different behavior, same failure
  * |ggplot2_3.5.2| installed from CRAN (source) and from p3m.dev (mac
    binary), same behavior
  * |kableExtra_1.4.0| installed from p3m.dev, and
    |remotes::install_github("haozhu233/kableExtra")| installed
    |1.4.0.15|, same behavior
  * R from the shell and R from emacs/ess
  * I tried |library(kableExtra); detach("package:kableExtra",
    unload=TRUE)| (no attempt to print) and it still erred/broke
  * though I think it was a red-herring, I have uninstalled XQuartz, no
    change
  * this has been in multiple versions of R-4.4, not just 4.4.3, and not
    just one download/install; I have not yet tried R-4.5
  * XCode updated itself to 16.2 (I don?t recall upgrading it), though I
    would not expect this to be an issue if I compiled neither R nor the
    packages using its compilers; I?m happy to be wrong here!

I do not think that the two packages have any collisions, 
|intersect(ls(getNamespace("ggplot2")), ls(getNamespace("kableExtra")))| 
yields nothing in common. But since this repros with base graphics 
without |ggplot2| loaded, that?s a non-player anyway.

I?m hoping someone here can help with a couple requests/questions:

  * can anyone else repro this on their machine, or is it just me?
  * any ideas of what I might try to recompile, reinstall, or otherwise
    debug or deep-dive to see if there are any clear markers of what is
    causing the error?

Thanks!
Bill
On 6/2/25 17:28, Kasper Daniel Hansen wrote:

            
&#8203;
#
More information, in case it?s useful:

  * I installed RStudio, and does not show this problem, but then again
    the |cmd-p| is not a keyboard thing in its graphics pane, and it
    uses the |RStudioGD| and |quartz_off_screen| devices vice |quartz|
  * I installed R-4.5.1 (which is matched better with the version of
    Xcode on my system, 16.2), and it still fails in the same way, so it
    seems unlikely to be a Xcode version thing
  * changing various |quartz.options(family=, dpi=, type=, bg=,
    canvas=)| does not change the behavior
  * this seems mostly about the printer connection:
      o both |cmd-p| (Print) and |cmd-shift-p| (Page Setup) evoke the
        failure
      o the Print and Page Setup menu items also trigger the failure
        without the keyboard shortcut
      o all other menu items and keyboard shortcuts (e.g., |cmd-c|) work
        without error
  * I do have printers installed and I do have a default printer; I?m not
    sure what happened with the previous ?no default printer? thing but now
    the print dialog does show a default printer available

It seems wholly tied to how |quartz| ties into the printer.

The keypress in question |cmd-p| in emacs is ?previous input/expression? 
(command history), which is something I use almost every minute. Since I 
tend to trigger it often enough by switching from emacs to the graphics 
window and then back to emacs and rerunning the previous command with a 
slight change (and clearly switching windows is an imperfect step for 
me), one trick that macos supports is overriding menu keyboard shortcuts 
for specific app menu items. Unfortunately, the quartz window is very 
special, and not one keyboard-shortcut app out there (specifically base 
macos, BetterTouchTool, nor Karabiner) recognizes quartz windows correctly.

So my workaround is to change the menu-item ?Print? (and Page Setup, 
just in case) for all applications to something else. Fortunately, I use 
that keypress to print something less than once per month, possibly once 
per year, I think I will not miss it.

I?m still curious if anybody else can reproduce this issue. If not, then 
something about my system is different enough :-(

Thanks for your attention :-)
Bill
On 7/3/25 22:55, bill+rsigmac at 8pawexpress.com wrote:

            
&#8203;
1 day later
#
Sorry, I can?t reproduce.  The second Cmd-P behaves as expected
with Apple M1 Max, emacs 29.4, ESS 24.01.1 and?


R Under development (unstable) (2024-11-10 r87316) -- "Unsuffered Consequences"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
R Under development (unstable) (2024-11-10 r87316)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.7.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] ggplot2_3.5.1

loaded via a namespace (and not attached):
[1] labeling_0.4.3   utf8_1.2.4       R6_2.5.1         tidyselect_1.2.1
[5] farver_2.1.2     magrittr_2.0.3   gtable_0.3.6     glue_1.8.0
 [9] tibble_3.2.1     pkgconfig_2.0.3  generics_0.1.3   dplyr_1.1.4
[13] lifecycle_1.0.4  cli_3.6.3        fansi_1.0.6      scales_1.3.0
[17] grid_4.5.0       vctrs_0.6.5      withr_3.0.2      compiler_4.5.0
[21] tools_4.5.0      munsell_0.5.1    pillar_1.9.0     colorspace_2.1-1
[25] rlang_1.1.4
--
Rodney Sparapani, Associate Professor of Biostatistics
President, Wisconsin Chapter of the American Statistical Association
Division of Biostatistics, Data Science Institute
Medical College of Wisconsin, Milwaukee Campus


From: R-SIG-Mac <r-sig-mac-bounces at r-project.org> on behalf of bill+rsigmac at 8pawexpress.com <bill+rsigmac at 8pawexpress.com>
Date: Friday, July 4, 2025 at 12:33?AM
To: r-mac <r-sig-mac at r-project.org>
Subject: Re: [R-SIG-Mac] quartz hanging
ATTENTION: This email originated from a sender outside of MCW. Use caution when clicking on links or opening attachments.
________________________________

Okay, it took me a while, but I now have a very small reprex for quartz
(not xquartz) failing. I cannot repro this on linux with R-4.4.3 and the
same package versions.

This is using emacs/ess, though it behaves the same on the console. I do
not have RStudio installed.

|R.version # _ # platform aarch64-apple-darwin20 # arch aarch64 # os
darwin20 # system aarch64, darwin20 # status # major 4 # minor 4.3 #
year 2025 # month 02 # day 28 # svn rev 87843 # language R #
version.string R version 4.4.3 (2025-02-28) # nickname Trophy Case
Sys.info()[c("release","version")] # release # "24.5.0" # version #
"Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025;
root:xnu-11417.121.6~2/RELEASE_ARM64_T6041" plot(1:10) |

(This can also be reproduced using |ggplot(mtcars, aes(mpg, disp)) +
geom_point()|.)

At this point, change to the quartz window, it looks fine. Press |cmd-p|
and a print dialog comes up, normal. Escape out. Press |cmd-p| again,
and a bunch of rows dump all at once:

|2025-07-03 22:12:31.320 R[85631:98913917] The behavior of the
UICollectionViewFlowLayout is not defined because: 2025-07-03
22:12:31.320 R[85631:98913917] the item width must be less than the
width of the UICollectionView minus the section insets left and right
values, minus the content insets left and right values. 2025-07-03
22:12:31.320 R[85631:98913917] The relevant UICollectionViewFlowLayout
instance is <NSCollectionViewFlowLayout: 0x15b623740>, and it is
attached to <NSCollectionView: 0x15b623000>. 2025-07-03 22:12:31.320
R[85631:98913917] Make a symbolic breakpoint at
UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the
debugger. 2025-07-03 22:12:31.322 R[85631:98913917] The behavior of the
UICollectionViewFlowLayout is not defined because: 2025-07-03
22:12:31.322 R[85631:98913917] the item width must be less than the
width of the UICollectionView minus the section insets left and right
values, minus the content insets left and right values. 2025-07-03
22:12:31.322 R[85631:98913917] The relevant UICollectionViewFlowLayout
instance is <NSCollectionViewFlowLayout: 0x15b623740>, and it is
attached to <NSCollectionView: 0x15b623000>. 2025-07-03 22:12:31.322
R[85631:98913917] Make a symbolic breakpoint at
UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the
debugger. 2025-07-03 22:12:31.324 R[85631:98913917] The behavior of the
UICollectionViewFlowLayout is not defined because: 2025-07-03
22:12:31.324 R[85631:98913917] the item width must be less than the
width of the UICollectionView minus the section insets left and right
values, minus the content insets left and right values. 2025-07-03
22:12:31.324 R[85631:98913917] The relevant UICollectionViewFlowLayout
instance is <NSCollectionViewFlowLayout: 0x15b623740>, and it is
attached to <NSCollectionView: 0x15b623000>. 2025-07-03 22:12:31.324
R[85631:98913917] Make a symbolic breakpoint at
UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the
debugger. |

(Repeating the |cmd-p| for the above messages is not required, it?s just
an oh-by-the-way. Not sure why it?s complaining, and I don?t entirely
understand what the messages are really saying. But since it?s neither a
warning nor a device-breaking error, I have been ignoring them.)

Now, load |kableExtra|. I haven?t tried many other packages, so far it
is just this one package.

|library(kableExtra) |

That?s all, no more code/expressions/evaluation required. Back to the
quartz window and press again |cmd-p|, and on the R console one of these
errors appears. I say ?one of? because it varies slightly based on base
graphics or ggplot2, or CRAN-vs-P3M ggplot2. Since the message-component
is the same, I believe it to be the same underlying problem.

|### with base graphics alone, I see this: Error in
getNamespace("grDevices") : Start tag expected, '<' not found [4] ###
using ggplot2 from P3M, this is the only message I see Error in
diff.default(xscale) : Start tag expected, '<' not found [4] ### using
ggplot2 from CRAN, I see the p3m-error above or one of these two Error
in length(x) : Start tag expected, '<' not found [4] Error in is.unit(y)
: Start tag expected, '<' not found [4] |

The quartz window for that R process is now unresponsive, R will plot
nothing more, and R will not open a new quartz window. I can |dev.off()
; dev.list()| and it suggests there are no windows, but the window is
still present and unresponsive. |dev.new()| does nothing. Additional
plot expressions (base or grid) do nothing, no error or warning, no
rendering.

Interestingly, when I do this with base graphics, the print dialog
remains up and is now unresponsive. (Does it matter that it says ?no
printer found??) When I repro this using |ggplot2|, the print dialog
does go away when the error hits, suggesting it is slightly later in
code execution?

Variations attempted:

  * R is just the default R installer, I have not compiled it or any of
    its components manually;
  * base graphics vs |ggplot2| grid, barely-different behavior, same failure
  * |ggplot2_3.5.2| installed from CRAN (source) and from p3m.dev (mac
    binary), same behavior
  * |kableExtra_1.4.0| installed from p3m.dev, and
    |remotes::install_github("haozhu233/kableExtra")| installed
    |1.4.0.15|, same behavior
  * R from the shell and R from emacs/ess
  * I tried |library(kableExtra); detach("package:kableExtra",
    unload=TRUE)| (no attempt to print) and it still erred/broke
  * though I think it was a red-herring, I have uninstalled XQuartz, no
    change
  * this has been in multiple versions of R-4.4, not just 4.4.3, and not
    just one download/install; I have not yet tried R-4.5
  * XCode updated itself to 16.2 (I don?t recall upgrading it), though I
    would not expect this to be an issue if I compiled neither R nor the
    packages using its compilers; I?m happy to be wrong here!

I do not think that the two packages have any collisions,
|intersect(ls(getNamespace("ggplot2")), ls(getNamespace("kableExtra")))|
yields nothing in common. But since this repros with base graphics
without |ggplot2| loaded, that?s a non-player anyway.

I?m hoping someone here can help with a couple requests/questions:

  * can anyone else repro this on their machine, or is it just me?
  * any ideas of what I might try to recompile, reinstall, or otherwise
    debug or deep-dive to see if there are any clear markers of what is
    causing the error?

Thanks!
Bill
On 6/2/25 17:28, Kasper Daniel Hansen wrote:

            
&#8203;

_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac at r-project.org
https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-sig-mac__;!!H8mHWRdzp34!-YEpBLrLI6b_Mk0zf1f5h0O-bWSg2UBs07TqCgYQIYE-X-ULQQ1uoZD_NBd2nUVAzcNTm05C3SDAzebn0WuSPVCkDVU$<https://urldefense.com/v3/__https:/stat.ethz.ch/mailman/listinfo/r-sig-mac__;!!H8mHWRdzp34!-YEpBLrLI6b_Mk0zf1f5h0O-bWSg2UBs07TqCgYQIYE-X-ULQQ1uoZD_NBd2nUVAzcNTm05C3SDAzebn0WuSPVCkDVU$>
#
Thank you for trying it, but you did not execute the reprex completely: 
you never loaded |kableExtra|. The reprex in-short (I should have 
included it this way the first time):

|plot(1:2) # or ggplot(mtcars, aes(mpg, disp)) + geom_point() # with the 
quartz window active, press Cmd-P, no fail library(kableExtra) # with 
the quartz window active, press Cmd-P, fail |

I must say that I?ve not seen this before:

|&gt; sessionInfo() R Under development (unstable) (2024-11-10 r87316) |

so it?s not clear to me what version of R you are actually using; based 
on the ?2024-11-10? timestamp, I can guess it?s R-4.4.2. Is |R.version| 
less vague about this?

BTW: a colleague of mine has the same MBP (M4) on Sequoia 15.5, R-4.4.3, 
and he can reproduce the fail. Since we are both on Sequoia 15.5 and you 
are on 14.7.2, perhaps it?s an OS thing, but it would be interesting if 
you reproduce it when you execute the reprex completely.

Bill
On 7/5/25 16:59, Sparapani, Rodney wrote:

            
&#8203;
#
I hope this is more readable as a regexp (for me your |-delimited blocks show up as a single line of text so it's very difficult to figure out which commands I'm supposed to execute).

	plot(1:2)
	# press Cmd-P in quartz window ? works
	library(kableExtra)
	# press Cmd-P in quartz window ? error, hangs, options(error=browser) doesn't help

The first lines were just intended to show that kableExtra is actually the culprit ? which is not quite true. The real cause of the error seems to be the xml2 package imported by kableExtra.  I get the same problem with this sequence

	library(xml2)
	plot(1:2)
	# press Cmd-P in quartz window ? error, hangs, options(error=browser) doesn't help
	
I have reproduced this on MacBook M1Max, macOS Sonoma 14.7.6, R 4.5.1 RC (2025-06-05 r88292) in a command-line session, so no Emacs/ESS involved.

Best,
Stephanie

  
  
#
The mailing lists strip html formatting... what you see is not what we see unless you set your email client program to compose and send plain text.
On July 6, 2025 8:21:39 AM PDT, Stephanie Evert <stefanML at collocations.de> wrote:

  
    
#
On 7/6/25 11:21, Stephanie Evert wrote:

            
Thank you for verifying and digging deeper! I was making no assumption 
(yet) that kableExtra was the clear problem; while it does import 
grDevices and graphics, I wouldn?t expect a simple import to do it. 
Having said that, xml2 imports neither package directly. In fact, 
loading each of xml2?s imports does not trigger the error, so that 
suggests it?s either in xml2?s ?./src/*? files or linking against libxml2.

I apologize for the formatting issue. I use Markdown Here Revival for 
Thunderbird/Betterbird so that I can type in markdown and have it 
rendered into HTML. It surprises me only a little that the stripped-out 
html leaves a bit to be desired.
On 7/6/25 11:44, Jeff Newmiller via R-SIG-Mac wrote:

            
That makes sense, I?d forgotten about that.

Bill
&#8203;
#
On 7/6/25 11:21, Stephanie Evert wrote:

            
Thank you for verifying and digging deeper! I was making no assumption 
(yet) that kableExtra was the clear problem; while it does import 
grDevices and graphics, I wouldn?t expect a simple import to do it. 
Having said that, xml2 imports neither package directly. In fact, 
loading each of xml2?s imports does not trigger the error, so that 
suggests it?s either in xml2?s ?./src/*? files or linking against libxml2.

I apologize for the formatting issue. I use Markdown Here Revival for 
Thunderbird/Betterbird so that I can type in markdown and have it 
rendered into HTML. It surprises me only a little that the stripped-out 
html leaves a bit to be desired.

Bill

&#8203;
1 day later
#
I raised https://github.com/r-lib/xml2/issues/458 and Jeroen was able to 
determine a resolution within the |xml2| package having to do with 
global error handlers and how libxml2 handles errors.

He made a commit 
https://github.com/r-lib/xml2/commit/b05d22a6e72bf94ce58a1483344db477969a9a98. 
After installing that reference, I can no longer trigger the error. I 
don?t know the intended CRAN timeline, but I would expect any CRAN 
version newer than 1.3.8 should have the fix.

Thanks to Stephanie Evert for finding the real culprit! And thanks to 
all others who contributed to the discussion.

Bill
On 7/6/25 13:04, Bill Evans wrote:

            
&#8203;