This might be a technical limitation, but my app sometimes opens 2 or more instances of itself and they all have to "merge" into the main window. The "onSecondWindow" callback gets called only once. The only fix I've found for this is adding a random sleep at the beginning of the app's lifecycle, which is probably some of the worst code I've written in a while.