sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
810 stars 39 forks source link

[ST4] Broken text rendering on macOS when "hardware_acceleration" is "opengl" #3794

Closed dmitshur closed 3 years ago

dmitshur commented 3 years ago

Description

There's some sort of issue with text rendering with this version of Sublime Text on an MacBook Air with an Apple M1 chip. It doesn't happen with a stable build of Sublime Text 3 on the same computer.

Steps to reproduce

  1. Open Sublime Text.
  2. Open Preferences → Settings.
  3. Scroll up and down with mouse or trackpad or keyboard, switch to other windows and back.

Expected behavior

Normal text rendering behavior at all times, as in Sublime Text 3.

Screenshot ![image](https://user-images.githubusercontent.com/1924134/100493367-35f7e200-3104-11eb-9445-95c3e8126681.png)

Actual behavior

Text rendering appears broken some of the time or most of the time. Starting around middle of the screen, most characters become invisible. As you scroll or move mouse or switch between tabs or windows, it sometimes flickers to rendering okay temporarily.

image

Environment

dmitshur commented 3 years ago

Note that this happens even with the default font face and other settings:

Screenshot ![image](https://user-images.githubusercontent.com/1924134/100493714-b409b800-3107-11eb-8310-75151f3ad563.png)
dmitshur commented 3 years ago

I found that the same bug was described in https://discord.com/channels/280102180189634562/280157083356233728/780817991159382077.

A workaround that was suggested there is to force "hardware_acceleration": "none". I can confirm the issue no longer happens after that setting is applied and ST4 is restarted.

dlehman commented 3 years ago

I was also experiencing this text rendering bug with build 4094 on MacBook Pro (M1). Confirm turning off hardware acceleration resolves issue.

ephemer commented 3 years ago

Turning off hardware acceleration does make the flickering stop, but the performance is noticeably (and unsurprisingly) poor.

As far as I know ST doesn't have an FPS meter so I can only guess, but I think it'd be lucky to be getting >20 FPS while scrolling on this specced-out M1 MacBook Pro. At those speeds, suddenly other editors are looking more tempting.

Are there any plans to revisit this? I seem to remember seeing talk of a Metal rendering backend somewhere

wbond commented 3 years ago

Can someone test and see how the results are on build 4092? I don't have an M1 Mac, but there were some tweaks between 4092 and 4093 and I'm curious if they affected things for users with an M1.

dmitshur commented 3 years ago

@wbond I tried build 4092 on an M1 Mac (with macOS 11.1) just now, and I can confirm it has the same problem as reported in the original issue that I'm also seeing in the latest build, 4094.

wbond commented 3 years ago

@dmitshur Thanks for checking so quickly! Would you mind trying 4086 also?

dmitshur commented 3 years ago

No problem. I've tested build 4086 and can confirm the issue does not reproduce in it.

If it would help, I'm happy to test the builds in between to bisect this further.

wbond commented 3 years ago

Excellent, at least I know the likely cause! That should help identify a word-around.

Do you see any performance issues running 4086? Specifically looking at the FPS when scrolling a large, maximized window via the scroll bar would be a useful data point.

dmitshur commented 3 years ago

Do you see any performance issues running 4086?

Short answer, no performance issues.

Longer answer. I tried at 2560x1600 (13" Retina) only so far, maximized window. Unless there's some way to display an FPS counter, the best I can tell with my eyes is to categorize performance into two categories: "fast" (45±15 FPS) and "slow" (20±10 FPS). With hardware_acceleration set to opengl in build 4086, performance is in the fast category. This is the same category where I'd place ST3 with its gpu_window_buffer set to the default auto. With hardware_acceleration set to none, performance is in the slow category (also see https://github.com/sublimehq/sublime_text/issues/3794#issuecomment-742512644 above).

wbond commented 3 years ago

In the console you can execute: sublime.log_fps(True).

wbond commented 3 years ago

Can someone with an M1 post their OpenGL debug info from the Sublime Text console?

dmitshur commented 3 years ago

Thanks for the log FPS command suggestion. I'm seeing numbers around 120 FPS maximum when scrolling a full-screen window at 2560x1600 with hardware_acceleration set to opengl:

fps: 117.8 average: 2ms
fps: 117.6 average: 2ms
fps: 118.2 average: 2ms
fps: 115.8 average: 2ms
fps: 115.6 average: 3ms
fps: 119 average: 2ms
fps: 118.8 average: 2ms
fps: 116.8 average: 2ms

(It's about the same with builds 4094 and 4086.)

With hardware_acceleration set to none, it seems to say around 30 FPS but with many other messages in between:


``` [...] Frame time exceeded 60hz: 1.60697e+07ms Frame time exceeded 60hz: 1.60697e+07ms Frame time exceeded 60hz: 1.60697e+07ms fps: 31 average: 1.55509e+07ms Frame time exceeded 60hz: 1.60698e+07ms Frame time exceeded 60hz: 1.60698e+07ms Frame time exceeded 60hz: 1.60698e+07ms [26 similar lines] Frame time exceeded 60hz: 1.60707e+07ms Frame time exceeded 60hz: 1.60708e+07ms Frame time exceeded 60hz: 1.60708e+07ms fps: 30.9 average: 1.55681e+07ms Frame time exceeded 60hz: 1.60708e+07ms Frame time exceeded 60hz: 1.60709e+07ms Frame time exceeded 60hz: 1.60709e+07ms [26 similar lines] Frame time exceeded 60hz: 1.60718e+07ms Frame time exceeded 60hz: 1.60718e+07ms Frame time exceeded 60hz: 1.60719e+07ms fps: 31.5 average: 1.55692e+07ms Frame time exceeded 60hz: 1.60719e+07ms Frame time exceeded 60hz: 1.60719e+07ms Frame time exceeded 60hz: 1.6072e+07ms [29 similar lines] Frame time exceeded 60hz: 1.60729e+07ms Frame time exceeded 60hz: 1.60729e+07ms Frame time exceeded 60hz: 1.60729e+07ms fps: 35 average: 1.56133e+07ms Frame time exceeded 60hz: 1.60729e+07ms Frame time exceeded 60hz: 1.60729e+07ms Frame time exceeded 60hz: 1.6073e+07ms ```

By "OpenGL debug info" are you referring to https://www.sublimetext.com/docs/gpu_rendering.html#diagnostics:ver-dev? If so, here:

OpenGL Context Information:
  GL API Version: 4.1 Metal - 71.0.7
  GLSL Version: 4.10
  Vendor: Apple
  Renderer: Apple M1

If there's more I can do to help, please let me know.

Endogen commented 3 years ago

I think it's worth noting that it's not only the editor but also the minimap that has issues with this. Should look like this:

image

But sometimes looks like this:

image

MacBook Pro M1 & Sublime Text 4094

EDIT: Oh and i just noticed that the issues are there even with "hardware_acceleration": "none"

BenjaminSchaaf commented 3 years ago

Fixed in build 4095.