# OSX - Occasional Slow Window Creation

**URL:** <https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732>\
**Category:** support\
**Created:** [August 16, 2016, 7:40am UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732 "2016-08-16T07:40:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sheado](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Sheado](https://discourse.glfw.org/u/Sheado)\
**Post date:** [August 16, 2016, 7:40am UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/1 "2016-08-16T07:40:37Z")

</div>

Hi All,

From time to time, glfwCreateWindow will take up to 50 seconds to return on OSX. This seems to occur most often on a fresh boot of the machine or if the game hasn’t been started in a few hours. Under normal circumstances, it completes within 1 second and everything is fine. I’m using GLFW v3.2 in my game and testing fullscreen window creation on an iMac running the latest OSX.

Any ideas what could be causing this and if there’s a workaround?

Thanks!

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 16, 2016, 11:47am UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/2 "2016-08-16T11:47:03Z")

</div>

I have never encountered that. It should not happen. What kind of system is it? What version of OS X is it running?

---

<div class="post-metadata">

**Author:** ![Sheado](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Sheado](https://discourse.glfw.org/u/Sheado)\
**Post date:** [August 16, 2016, 7:34pm UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/3 "2016-08-16T19:34:41Z")

</div>

Hi,

Here’s all the info:

Dual monitor - with fullscreen window creating on the primary monitor (I’m trying to reproduce it in single monitor, but it’s a pain to reproduce with a reboot each time)

OSX 10.11.6  
iMac (21.5-inch, Late 2012)  
Processor 2.7 GHz Intel Core i5  
Memory 8 GB 1600 MHz DDR3  
Graphics NVIDIA GeForce GT 640M 512 MB

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 16, 2016, 8:07pm UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/4 "2016-08-16T20:07:03Z")

</div>

What is the output of `tests/events -f` on that system? You can quit it with Cmd+Q.

---

<div class="post-metadata">

**Author:** ![Sheado](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Sheado](https://discourse.glfw.org/u/Sheado)\
**Post date:** [August 16, 2016, 8:31pm UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/5 "2016-08-16T20:31:59Z")

</div>

Here you go:

**Dual screen (first attempt):**  
Library initialized  
Creating full screen window 1 (1920x1080 on iMac)  
Main loop starting  
00000000 to 1 at 0.550: Window refresh  
00000001 to 1 at 2.058: Window focused  
00000002 to 1 at 2.061: Cursor entered window  
00000003 to 1 at 4.875: Key 0x0157 Scancode 0x0037 (LEFT SUPER) (with super) was pressed  
00000004 to 1 at 5.225: Window close

**Single monitor:**  
Library initialized  
Creating full screen window 1 (1920x1080 on iMac)  
Main loop starting  
00000000 to 1 at 0.526: Window refresh  
00000001 to 1 at 0.678: Window focused  
00000002 to 1 at 0.681: Cursor entered window  
00000003 to 1 at 3.025: Key 0x0157 Scancode 0x0037 (LEFT SUPER) (with super) was pressed  
00000004 to 1 at 4.369: Window close

**Dual monitor (after plugging monitor back in):**  
Library initialized  
Creating full screen window 1 (1920x1080 on iMac)  
Main loop starting  
00000000 to 1 at 0.538: Window refresh  
00000001 to 1 at 0.700: Window focused  
00000002 to 1 at 0.703: Cursor entered window  
00000003 to 1 at 2.811: Key 0x0157 Scancode 0x0037 (LEFT SUPER) (with super) was pressed  
00000004 to 1 at 3.310: Window close

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [August 17, 2016, 6:46pm UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/6 "2016-08-17T18:46:45Z")

</div>

Without knowing what OS call is taking so long, I’m afraid I don’t know what to do. How often does this delay happen? Would you be able to profile it while it happens, or find it with a debugger?

---

<div class="post-metadata">

**Author:** ![Sheado](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Sheado](https://discourse.glfw.org/u/Sheado)\
**Post date:** [August 17, 2016, 10:16pm UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/7 "2016-08-17T22:16:55Z")

</div>

I see - thanks for looking into this. I’ll try to profile or debug and I’ll report back if I find anything.

It happens the first time the game is launched since the last boot of the machine - so unfortunately that might mean a bad first impression for the first launch of my game on dual screen OSX machines. It also seems to happen again after a couple of hours - perhaps something the OS caches is reclaimed leading to the delay the next time the game launches.

---

<div class="post-metadata">

**Author:** ![Sheado](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Sheado](https://discourse.glfw.org/u/Sheado)\
**Post date:** [September 9, 2016, 3:06am UTC](https://discourse.glfw.org/t/osx-occasional-slow-window-creation/732/8 "2016-09-09T03:06:35Z")

</div>

Hi,

Just wanted to follow up on this.  
I tried profiling with no luck. For some reason any time the profiler is running, the game loads up fast. Maybe that’s a clue?
