Skip to content
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

Delaying texture copy creates flicker #8

Open
mihe opened this issue Apr 3, 2018 · 3 comments
Open

Delaying texture copy creates flicker #8

mihe opened this issue Apr 3, 2018 · 3 comments
Assignees

Comments

@mihe
Copy link
Contributor

mihe commented Apr 3, 2018

... when not using CefBrowserHost::SendExternalBeginFrame and instead just relying on CEF to do the frame requests itself.

Basically, the implementation of OnAcceleratedPaint in our own application can sometimes take a while to actually perform the copy from the shared texture. It seems like that delay sometimes causes a blank texture to be copied, resulting in it flickering on and off at random times.

We managed to reproduce the issue with the HUD view in this branch of cefmixer, using .\cefmixer.exe --sleep=30 about:blank. The branch just removes the usage of SendExternalBeginFrame and puts a Sleep(...) in FrameBuffer::on_paint to simulate some arbitrary delay between OnAcceleratedPaint being called and the frame actually getting copied. You might have to tweak the length of the sleep in order to reproduce it yourself though.

Here's a small clip showing what it looks like.

Having the application's own vsync on or off doesn't seem to matter, but toggling it can sometimes force the issue to appear.

@mihe mihe changed the title Delaying texture copy makes textures flicker Delaying texture copy creates flicker Apr 3, 2018
@wesselsga
Copy link
Contributor

wesselsga commented Apr 4, 2018

I've also been fighting a flickering issue on older AMD-based hardware. I ended up modifying the pull request so that when not using keyed mutexes ... Chromium will use a stand-alone texture (non-render target) that is marked as shared and the FBO will be bound to a non-shared texture. Then CopyResource is used in Chromium to update the shared texture.

I also updated cefmixer to not use keyed mutexes currently. I was able to reproduce the issue using your sleep option and I believe it should now work if you disable keyed mutexes with:

window_info.shared_texture_sync_key = uint64_t(-1);

When using this option, I didn't see any flickering using CEF's timing or SendExternalBeginFrame.

I think the keyed mutex option should be modified to lock/unlock in sequence vs. always using key 0. That is acquire(0) -> release(1) -> acquire(1) -> release(0) to have Chromium and the application access the mutex in sequence ... but I have been unsuccessful in getting this working yet.

For our commercial application, I'm simply using the non-keyed mutex path.

@wesselsga wesselsga self-assigned this Apr 4, 2018
@mihe
Copy link
Contributor Author

mihe commented Apr 4, 2018

For what it's worth, we're seeing this issue on both AMD RX 580 and Nvidia GTX 970. I've also seen the issue happen with SendExternalBeginFrame in our own application, but unfortunately I can't reproduce that in cefmixer.

I'll pull down your latest changes and give the non-keyed mutex path a try.

@mihe
Copy link
Contributor Author

mihe commented Apr 5, 2018

Can confirm that disabling keyed mutex texture fixed the flickering issue. Thanks!

blattersturm pushed a commit to citizenfx/fivem that referenced this issue Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants