Rstudio and OpenCV C/C++ macOS 10.13.6 needing daily build to avoid crashes with Cocoa


I maintain a package that uses Rcpp to call OpenCV which then does some image processing and displays the results using OpenCVs high-level GUI (which uses cocoa on macOS

Lately everytime Apple releases a new version users that use R through Rstudio have been reporting crashes when high-level GUI windows are closed by OpenCV (using cv::destroyAllWindows(); from OpenCV C++). This issue is usually resolved by installing Rstudio daily build which is compiled with latest release of macOS.

The issue never happens if the same R code is executed through R from the terminal.

Another observation I've seen that is specific to running OpenCV C++ code from Rstudio is that windows that are closed by cv::destroyWindow() or cv::destroyAllWindows() will be made inactive but still open whereas running R from the terminal the windows will close.

Any advice or suggestion on how I can avoid telling users of the package to upgrade Rstudio to daily build everytime they upgrade macOS?

We're hoping to start promoting a preview release of RStudio v1.2 in the coming months, and with some luck we'll have the v1.2 release out the door by the end of the year.

I'd recommend asking users to install the latest preview release as it's unlikely this issue will be resolved in the v1.1 branch.