flowkey / UIKit-cross-platform

Cross-platform Swift implementation of UIKit, mostly for Android
MIT License
600 stars 40 forks source link

Guard window in render loop #191

Closed janek closed 6 years ago

janek commented 6 years ago

Fixes # https://github.com/flowkey/smartphone-app/issues/977 (possibly only partly)

Type of change: Bug fix / improving code stability

Motivation

The problem relates to https://github.com/flowkey/smartphone-app/issues/977 (sometimes app crashes on player start from portrait) and also to https://app.zenhub.com/workspace/o/flowkey/smartphone-app/issues/979 (render loop called even after user exits Player).

The changes in this PR are supposed to ensure that the render loop in the native part of the code is not called if the window of the Native Player is not ready (e.g. not there anymore or not yet) as well as the Native Player does not ask for the rendering if it shouldn't.

While this might not solve the problem entirely, it's an easy step in the right direction and code that we need in any case.