title: AVCaptureVideoPreviewLayer (camera preview) freezes/stuck after moving to background and back
body: <p>Cant figure this one out.
  Everything works fine when the app is active, and than <strong>sometimes</strong> when i move the app to the background(pressing the home button) and than going back, the previewlayer freezes/stuck. 
  Im using viewWillAppear and viewDidAppear for the set up.
  This is how i set everything up :</p>
  
  <pre><code>  var backCamera = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo)
    var global_device : AVCaptureDevice!
    var captureSession: AVCaptureSession?
  
  override func viewWillAppear(animated: Bool) {
  super.viewWillAppear(animated)
  
  captureSession = AVCaptureSession()
          captureSession!.sessionPreset = AVCaptureSessionPresetPhoto
          CorrectPosition = AVCaptureDevicePosition.Back
          for device in backCamera {
              if device.position == AVCaptureDevicePosition.Back {
                  global_device = device as! AVCaptureDevice
                  CorrectPosition = AVCaptureDevicePosition.Back
                  break
              }
          }
  
  
          configureCamera()
          var error: NSError?
          var input = AVCaptureDeviceInput(device: global_device, error: &amp;error)
  
  
          if error == nil &amp;&amp; captureSession!.canAddInput(input) {
              captureSession!.addInput(input)
  
              stillImageOutput = AVCaptureStillImageOutput()
              stillImageOutput!.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
              if captureSession!.canAddOutput(stillImageOutput) {
                  captureSession!.addOutput(stillImageOutput)
  
                  previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
                  var bounds:CGRect = camera_Preview.layer.bounds
                  previewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
                  previewLayer?.bounds = bounds
                  previewLayer?.position = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds))
                  camera_Preview.layer.addSublayer(previewLayer)
                  self.view.bringSubviewToFront(camera_Preview)
                  self.view.bringSubviewToFront(nan_view)
  
                  captureSession!.startRunning()
  
  
              }
          }
  </code></pre>
  
  <p>ViewDidAppear :</p>
  
  <pre><code>  var previewLayer: AVCaptureVideoPreviewLayer?
  
  
  override func viewDidAppear(animated: Bool) {
          super.viewDidAppear(animated)
          previewLayer!.frame = camera_Preview.bounds
      }
  </code></pre>