New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support vsync, refactor rendering, rendering tests #44
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Split onRender into performUpdate and performDraw. performUpdate will be called from the Swing thread in upcoming commits (to avoid race conditions) 2. Remove canvas.scale by default Motivation: automatic scaling is harmful. Example: - skiko returns us 100x100 canvas size. - We load image from disk and reduce its size to 100x100. - We draw this image onto canvas, and it is scaled 2x with artifacts. If skiko returns us 200x200 then we reduce image to 200x200 and draw it onto canvas without scaling. 3. Cache contentScale It is expensive operation on Linux to do it in every frame (we read database) 4. Remove onInit, onReshape, onDispose removed from SkiaRenderer. It is hard to implement it in the right thread (on macOs we have AppKit and AWT thread). Besides we don't use them in Compose. If they will be needed then we can implement them later.
igordmn
changed the title
Support vsync, refactor rendering
Support vsync, refactor rendering, rendering tests
Jan 15, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
samples/SkijaInjectSample/src/test/kotlin/org/jetbrains/skiko/ScreenshotTestRule.kt
Outdated
Show resolved
Hide resolved
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
olonho
reviewed
Jan 16, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fullscreen seems to be broken with this PR.
Rsedaikin
reviewed
Jan 18, 2021
Rsedaikin
reviewed
Jan 18, 2021
samples/SkijaInjectSample/src/main/kotlin/SkijaInjectSample/SkiaPanel.kt
Show resolved
Hide resolved
Rsedaikin
reviewed
Jan 18, 2021
olonho
approved these changes
Jan 19, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me, if fullscreen is fixed.
olonho
approved these changes
Jan 19, 2021
copybara-service bot
pushed a commit
to androidx/androidx
that referenced
this pull request
Jan 28, 2021
- SkiaLayer now produces a frame every vsync signal, so we don't have to use a timer [FrameDispatcher, `delay`]. The timer isn't precise and cause frame skipping. - needRedraw/FrameDispatcher now are part of SkiaLayer in skiko - onRender is now always called from AWT thread, so we don't have to create a temporarily picture [ComposeLayer, `preparePicture`] - we can use "throw e" instead of System.exit inside onRender, because it is a Java thread now [ComposeLayer, `onRender`] - use layer.contentScale instead of wrapped.graphicsConfiguration.defaultTransform.scaleX (in Linux it has wrong density) [ComposeLayer, `detectCurrentDensity`] - move initialization of DesktopOwner to SkiaLayer.init (layer.contentScale is available only after init) - now we don't have to manually call layer.reinit() and layer.updateLayer(), it is called automatically [ComposeWindow] - remove FPSTracker. FPS can be measured by adding systemProperty("skiko.fps.enabled", "true") inside build.gradle [ComposeWindow] Vsync test results: JetBrains/skiko#44 (comment) Change-Id: I45ccf56a325d9ea87af13c247f5fd959a9bc3618 Test: ./gradlew jvmTest desktopTest -Pandroidx.compose.multiplatformEnabled=true
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Better to look at every commit separately, not at PR entirely.
Results of ./gradlew runVsync in Compose with 5000 frames and 2 windows
Windows 10 19041.746, 100Hz display
After:
Before (FPS is low because on Windows we used system timer which has precision 15ms):
Ubuntu 20.04.1 LTS (X11 Window Manager), 100Hz display
After:
Before (everything was ok, but with two displays application was very laggy):
macOs Catalina, 60Hz display
After:
Before (system timer has resolution 1-3ms):
Deltas between frames with 3 opened windows (300 frames)
Windows (100Hz monitor)
Ubuntu (100Hz monitor)
macOs (60Hz monitor)