memoryio / memoryio-macosx

Life logging app for macosx. Takes a picture with built in isight whenever you wake computer from sleep
8 stars 4 forks source link

MemoryIO goes to 100% CPU usage when the camera is unavailable. #12

Closed zgiles closed 10 years ago

zgiles commented 10 years ago

If i have the system on an external screen with the lid closed (see [1] below for a description of how to have a camera off), the camera will not activate. Photobooth will tell me "The Camera is Off".

If memoryio is to take a picture, either from wake up or you "Force Photo", the memoryio process goes to 100% CPU usage on 1 core (single threaded) forever until you exit it. It's not in a "crashed" state -- Exiting it normally via the menu works, or force killing also works.

[1] in OS X 10.8+, if you plug in an external screen, like dvi via DP or Thunderbolt etc, And have a USB/ Bluetooth keyboard + mouse plugged in, And have your laptop on an AC adapter, And you close your lid, then your primary screen becomes the external screen, turning off the internal screen. It also "turns off" the camera. this is when the problem occurs.

Possible Solution: Check if the camera is ready (one exists, but it's not available / "is off") and skip that camera / noop.

zgiles commented 10 years ago

Happens like this... Console Logs: 10/20/13 5:14:35.588 PM Console[34887]: Marker - Oct 20, 2013 5:14:35 PM 10/20/13 5:14:40.658 PM com.apple.launchd.peruser.501[146]: ([0x0-0x1106105].com.apple.inputmethod.ironwood[37799]) Exited: Killed: 9 10/20/13 5:14:40.000 PM kernel[0]: memorystatus_thread: idle exiting pid 37799 [DictationIM] 10/20/13 5:14:41.040 PM _spotlight[37814]: audit warning: soft /var/audit 10/20/13 5:14:41.040 PM _spotlight[37812]: audit warning: allsoft 10/20/13 5:14:41.043 PM _spotlight[37813]: audit warning: closefile /var/audit/20131020210331.20131020211440 10/20/13 5:14:41.755 PM com.apple.SecurityServer[16]: Session 101130 created 10/20/13 5:14:50.442 PM memoryio[37801]: Starting device... 10/20/13 5:14:50.442 PM memoryio[37801]: Starting capture session... 10/20/13 5:14:50.443 PM memoryio[37801]: Creating QTCaptureSession... 10/20/13 5:14:50.444 PM memoryio[37801]: Done. 10/20/13 5:14:50.551 PM memoryio[37801]: Creating QTCaptureDeviceInput with FaceTime Camera (Built-in)... 10/20/13 5:14:50.552 PM memoryio[37801]: Done. 10/20/13 5:14:50.553 PM memoryio[37801]: Creating QTCaptureDecompressedVideoOutput... 10/20/13 5:14:50.554 PM memoryio[37801]: Done. 10/20/13 5:14:50.555 PM memoryio[37801]: Entering synchronized block to clear memory... 10/20/13 5:14:50.555 PM memoryio[37801]: Done. 10/20/13 5:14:50.556 PM memoryio[37801]: Session started. 10/20/13 5:14:50.556 PM memoryio[37801]: Device started. 10/20/13 5:14:50.557 PM memoryio[37801]: Delaying 2.00 seconds for warmup... 10/20/13 5:14:52.558 PM memoryio[37801]: Warmup complete. 10/20/13 5:14:52.559 PM memoryio[37801]: Taking snapshot... 10/20/13 5:14:52.559 PM memoryio[37801]: Entering synchronized block to see if frame is captured yet... 10/20/13 5:14:52.560 PM memoryio[37801]: Done. 10/20/13 5:14:52.560 PM memoryio[37801]: Entering synchronized block to see if frame is captured yet... 10/20/13 5:14:52.561 PM memoryio[37801]: Done. 10/20/13 5:14:52.561 PM memoryio[37801]: Entering synchronized block to see if frame is captured yet... 10/20/13 5:14:52.561 PM memoryio[37801]: Done. 10/20/13 5:14:52.562 PM memoryio[37801]: Entering synchronized block to see if frame is captured yet... 10/20/13 5:14:52.562 PM memoryio[37801]: Done. 10/20/13 5:14:52.563 PM memoryio[37801]: Entering synchronized block to see if frame is captured yet... Repeat the Sync Block for 10K more, about 4K errors per sec.

jacobrosenthal commented 10 years ago

Terribly tracked, but this was fixed for the 1.0.1 release d20294414ddf2b3152147f20965af0516c4879ff

Basically the old imagesnap code was waiting around forever to see if it could get a good frame. In all use cases we can observe we either get a good frame or we don't. Now, if we don't get a good frame, we'll just error out informing the user that we couldn't take a photo.