There is an undocumented limit on nesting calls to CFRunLoopRun (or the 
equivalent wrapper NSRunLoop methods). When the limit is hit the OS terminates 
the Java app. The situation arises when a JavaFX app creates too many nested 
event loops from within  Platform.runLater runnables.

This PR doesn't change the limit (which is 250+ nested loops) but it does throw 
an exception just before the limit is reached so a JavaFX developer will get a 
useful Java stack trace instead of an OS crash log.

On the Mac the nested event loop has two stages: first we ask the run loop to 
run, then we pull an event out and process it. A Platform.runLater runnable is 
executed in the first stage so if the runnable starts a new nested event loop 
the system will re-enter CFRunLoopRun. The same isn't true if an input event 
handler starts a new nested event loop; at that point we're in stage two and 
are past the call to CFRunLoopRun.

-------------

Commit messages:
 - Merge remote-tracking branch 'upstream/master' into toomanyloops
 - Moved some asserts so they're not inside runLater blocks.
 - Mac nows throws exception before we hit the limit on nested CFRunLoopRun 
calls

Changes: https://git.openjdk.org/jfx/pull/1741/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1741&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8351733
  Stats: 101 lines in 6 files changed: 92 ins; 0 del; 9 mod
  Patch: https://git.openjdk.org/jfx/pull/1741.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1741/head:pull/1741

PR: https://git.openjdk.org/jfx/pull/1741

Reply via email to