question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Program hang on quit on Mac OS X

See original GitHub issue

The program run and capture images properly but hang on exit and force quit is need on Mac (with Retina display) installed with OS X Yosemite (running inside eclipse).

17:46:30.145 [main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
17:46:30.151 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
17:46:30.476 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:30.478 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new resolution 320x240
17:46:30.478 [main] WARN com.github.sarxos.webcam.Webcam - Automated deallocation on TERM signal is now enabled! Make sure to not use it in production!
17:46:30.478 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:30.488 [atomic-processor-1] INFO c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:30.488 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Opening webcam device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:30.488 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device 0x1470000005ac8511 starting session, size java.awt.Dimension[width=320,height=240]
17:46:30.532 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device session started
17:46:30.532 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Initialize buffer
17:46:33.481 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
17:46:34.175 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice@be4535e is now open
17:46:34.175 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam is now open FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:34.176 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:34.219 [main] DEBUG c.github.sarxos.webcam.WebcamUpdater - Webcam updater has been started
17:46:34.225 [main] DEBUG com.github.sarxos.webcam.WebcamPanel - Starting panel rendering and trying to open attached webcam
17:46:37.181 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
17:46:37.213 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:40.217 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
17:46:40.246 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:43.247 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
17:46:43.253 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:45.653 [shutdown-hook-1] INFO c.g.sarxos.webcam.WebcamShutdownHook - Automatic FaceTime HD Camera (Built-in) 0x1470000005ac8511 deallocation
17:46:45.653 [shutdown-hook-1] INFO com.github.sarxos.webcam.Webcam - Disposing webcam FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:45.664 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Disposing webcam device FaceTime HD Camera (Built-in) 0x1470000005ac8511
17:46:45.664 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Closing webcam device
17:46:46.256 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices

The above is the message shown on eclipse console and hang after “Searching devices”.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
msj121commented, Jun 8, 2015

Just for the record, simply writing the static void main as follows:

public static void main(String[] args) {    
        Webcam.getDiscoveryService().setEnabled(true);
        Webcam.getDiscoveryService().stop();
        webcam = Webcam.getDefault();
        launch(args);
        while(running){
            try {
                Thread.currentThread().sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        webcam.close();
}

Now you can use the webcam in JavaFx. My assumption is natively the main thread needs to exist, or something… I hope this is a useable workaround for some.

Of course you need to set running = false, when your JavaFX application is done with the Webcam.

0reactions
reinaldoluckmancommented, Sep 30, 2016

The only way that I could solve this was by putting a shutdown hook with a halt:

if (System.getProperty("os.name").equals("Mac OS X")) {            

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            camMMOPanel.stop();
            camMMO.close();
            Runtime.getRuntime().halt(0);
        }
    });            
}

If someone has a better solution, please share.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to force an app to quit on your Mac - Apple Support
Force an app to quit · Press these three keys together: Option (or Alt), Command, Esc (Escape).* · Or choose Force Quit from...
Read more >
What happens when force quit doesn't work on your Mac?
A quick replacement for Force Quit is found in CleanMyMac X. This program by MacPaw has a tool that switches off your hanging...
Read more >
What to do when an app hangs in OS X - CNET
Try forcing the Finder to quit by using the Force-quit window (in the Apple menu), but you can also relaunch the Dock by...
Read more >
Apps Freeze or Quit Unexpectedly on macOS 10.14? How to Fix
1. Force-Quit and Restart the App ... You can quickly fix a frozen or unresponsive app by forcing it to quit if the...
Read more >
Apps Crash and Unexpectedly Quit on Mac - Macube Cleaner
Solution 1. Force quit the app. When the app gets frozen or unresponsive, you might as well try force quit it by going...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found