**Issue:** 
With metal pipeline, frame tearing is observed when scrolling the content. 
Perform small fling gesture scrolls for observing the issue, the issue 
occurs/observed easily when scroll is coming to and end.

**Cause:**
vsync is not enabled for metal pipeline.

**Fix:** 
1. Enable vsync for metal pipeline. The vsync shall be enabled by default. It 
can be disabled with `-Djavafx.animation.fullspeed=true`.
2. Synchronize the access to offline render target texture.
2.1 The `GlassMTLFrameBufferObject._texture` object is created and destroyed by 
**QuantumRenderer** thread, and
2.2 `GlassMTLFrameBufferObject._texture` is also accessed on **Appkit** thread 
through function `GlassLayerMTL.blitToScreen()`
2.3 NSLock is created to synchronize the acess
2.4 Without this synchronization, a crash could occur in scenario when JavaFX 
app window is moved between screens that differ in refresh rate.

**Verification:**
1. Test that no frame tearing is observed, when scrolling(easy to test with 
small fling scrolls)
2. Test no issue observed when moving window among screens.
3. General sanity testing of UI.

**Test:**
A unit or system test is not possible for this scenario.

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

Commit messages:
 - implement vsync for metal

Changes: https://git.openjdk.org/jfx/pull/1978/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1978&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8335748
  Stats: 147 lines in 11 files changed: 76 ins; 25 del; 46 mod
  Patch: https://git.openjdk.org/jfx/pull/1978.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1978/head:pull/1978

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

Reply via email to