I think you should debug the the process and handle the lifecycle
example : when pip mode is active, some lifecycle methods are triggered (onPause and onStop), debug these two and ensure that you are handling these lifecycle changes properly in your activity to avoid crashes.