We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] `TileRenderer` ignores the `visible` property
#### ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)
Bokeh 2.1.0rc1

#### Description of expected behavior and the observed behavior
`TileRenderer` should take into account the `visible` property. Both if passed to its constructor and if changed in runtime if using Bokeh server.

#### Complete, minimal, self-contained example code that reproduces the issue
```python
from bokeh.io import show
from bokeh.plotting import figure
from bokeh.tile_providers import CARTODBPOSITRON, get_provider

p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
           x_axis_type="mercator", y_axis_type="mercator")

p.add_tile(get_provider(CARTODBPOSITRON), visible=False)

show(p)
```
The root cause is that `TileRenderer` just doesn't check `visible` at all. It seems like every renderer checks this property. Maybe it should be checked at a higher level?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/models/file/latex_extension.py`
Content:
```
1 """ The LaTex example was derived from: http://matplotlib.org/users/usetex.html
2 """
3 import numpy as np
4 from scipy.special import jv
5 
6 from bokeh.models import Label
7 from bokeh.palettes import Spectral4
8 from bokeh.plotting import figure, output_file, show
9 from bokeh.util.compiler import TypeScript
10 
11 output_file('latex_extension.html')
12 
13 class LatexLabel(Label):
14     """A subclass of `Label` with all of the same class attributes except
15     canvas mode isn't supported and DOM manipulation happens in the TypeScript
16     superclass implementation that requires setting `render_mode='css'`).
17 
18     Only the render method of LabelView is overwritten to perform the
19     text -> latex (via katex) conversion
20     """
21     __javascript__ = ["https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.js"]
22     __css__ = ["https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css"]
23     __implementation__ = TypeScript("""
24 import {Label, LabelView} from "models/annotations/label"
25 
26 declare namespace katex {
27   function render(expression: string, element: HTMLElement, options: {displayMode?: boolean}): void
28 }
29 
30 export class LatexLabelView extends LabelView {
31   model: LatexLabel
32 
33   render(): void {
34     // Here because AngleSpec does units tranform and label doesn't support specs
35     let angle: number
36     switch (this.model.angle_units) {
37       case "rad": {
38         angle = -1 * this.model.angle
39         break
40       }
41       case "deg": {
42         angle = -1 * this.model.angle * Math.PI/180.0
43         break
44       }
45       default:
46         throw new Error("unreachable")
47     }
48 
49     const panel = this.panel || this.plot_view.frame
50 
51     const xscale = this.plot_view.frame.xscales[this.model.x_range_name]
52     const yscale = this.plot_view.frame.yscales[this.model.y_range_name]
53 
54     const {x, y} = this.model
55     let sx = this.model.x_units == "data" ? xscale.compute(x) : panel.xview.compute(x)
56     let sy = this.model.y_units == "data" ? yscale.compute(y) : panel.yview.compute(y)
57 
58     sx += this.model.x_offset
59     sy -= this.model.y_offset
60 
61     this._css_text(this.layer.ctx, "", sx, sy, angle)
62     katex.render(this.model.text, this.el, {displayMode: true})
63   }
64 }
65 
66 export class LatexLabel extends Label {
67   static init_LatexLabel(): void {
68     this.prototype.default_view = LatexLabelView
69   }
70 }
71 """)
72 
73 p = figure(title="LaTex Extension Demonstration", plot_width=800, plot_height=350,
74            background_fill_color="#fafafa")
75 p.x_range.range_padding = 0
76 
77 x = np.arange(0.0, 20.0, 0.02)
78 
79 for i, n in enumerate([0, 1, 4, 7]):
80     p.line(x, jv(n, x), line_width=3, color=Spectral4[i], alpha=0.8, legend_label="𝜈=%d" % n)
81 
82 
83 text = (r"\text{Bessel Functions of the First Kind: }" +
84         r"J_\nu = \sum_{m=0}^{\infty}\frac{(-1)^m}{m!\ \Gamma(m+\nu+1)}" +
85         r"\left(\frac{x}{2}\right)^{2m+\nu}")
86 latex = LatexLabel(text=text,x=4.5, y=250, x_units='data', y_units='screen',
87                    render_mode='css', text_font_size='11px',
88                    background_fill_color="white", border_line_color="lightgrey")
89 
90 p.add_layout(latex)
91 
92 show(p)
93
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/examples/models/file/latex_extension.py b/examples/models/file/latex_extension.py
--- a/examples/models/file/latex_extension.py
+++ b/examples/models/file/latex_extension.py
@@ -30,7 +30,7 @@
 export class LatexLabelView extends LabelView {
   model: LatexLabel
 
-  render(): void {
+  protected _render(): void {
     // Here because AngleSpec does units tranform and label doesn't support specs
     let angle: number
     switch (this.model.angle_units) {
@@ -59,13 +59,17 @@
     sy -= this.model.y_offset
 
     this._css_text(this.layer.ctx, "", sx, sy, angle)
-    katex.render(this.model.text, this.el, {displayMode: true})
+    katex.render(this.model.text, this.el!, {displayMode: true})
   }
 }
 
 export class LatexLabel extends Label {
   static init_LatexLabel(): void {
     this.prototype.default_view = LatexLabelView
+
+    this.override({
+      render_mode: "css",
+    })
   }
 }
 """)

{"golden_diff": "diff --git a/examples/models/file/latex_extension.py b/examples/models/file/latex_extension.py\n--- a/examples/models/file/latex_extension.py\n+++ b/examples/models/file/latex_extension.py\n@@ -30,7 +30,7 @@\n export class LatexLabelView extends LabelView {\n   model: LatexLabel\n \n-  render(): void {\n+  protected _render(): void {\n     // Here because AngleSpec does units tranform and label doesn't support specs\n     let angle: number\n     switch (this.model.angle_units) {\n@@ -59,13 +59,17 @@\n     sy -= this.model.y_offset\n \n     this._css_text(this.layer.ctx, \"\", sx, sy, angle)\n-    katex.render(this.model.text, this.el, {displayMode: true})\n+    katex.render(this.model.text, this.el!, {displayMode: true})\n   }\n }\n \n export class LatexLabel extends Label {\n   static init_LatexLabel(): void {\n     this.prototype.default_view = LatexLabelView\n+\n+    this.override({\n+      render_mode: \"css\",\n+    })\n   }\n }\n \"\"\")\n", "issue": "[BUG] `TileRenderer` ignores the `visible` property\n#### ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)\r\nBokeh 2.1.0rc1\r\n\r\n#### Description of expected behavior and the observed behavior\r\n`TileRenderer` should take into account the `visible` property. Both if passed to its constructor and if changed in runtime if using Bokeh server.\r\n\r\n#### Complete, minimal, self-contained example code that reproduces the issue\r\n```python\r\nfrom bokeh.io import show\r\nfrom bokeh.plotting import figure\r\nfrom bokeh.tile_providers import CARTODBPOSITRON, get_provider\r\n\r\np = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),\r\n           x_axis_type=\"mercator\", y_axis_type=\"mercator\")\r\n\r\np.add_tile(get_provider(CARTODBPOSITRON), visible=False)\r\n\r\nshow(p)\r\n```\r\nThe root cause is that `TileRenderer` just doesn't check `visible` at all. It seems like every renderer checks this property. Maybe it should be checked at a higher level?\n", "before_files": [{"content": "\"\"\" The LaTex example was derived from: http://matplotlib.org/users/usetex.html\n\"\"\"\nimport numpy as np\nfrom scipy.special import jv\n\nfrom bokeh.models import Label\nfrom bokeh.palettes import Spectral4\nfrom bokeh.plotting import figure, output_file, show\nfrom bokeh.util.compiler import TypeScript\n\noutput_file('latex_extension.html')\n\nclass LatexLabel(Label):\n    \"\"\"A subclass of `Label` with all of the same class attributes except\n    canvas mode isn't supported and DOM manipulation happens in the TypeScript\n    superclass implementation that requires setting `render_mode='css'`).\n\n    Only the render method of LabelView is overwritten to perform the\n    text -> latex (via katex) conversion\n    \"\"\"\n    __javascript__ = [\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.js\"]\n    __css__ = [\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css\"]\n    __implementation__ = TypeScript(\"\"\"\nimport {Label, LabelView} from \"models/annotations/label\"\n\ndeclare namespace katex {\n  function render(expression: string, element: HTMLElement, options: {displayMode?: boolean}): void\n}\n\nexport class LatexLabelView extends LabelView {\n  model: LatexLabel\n\n  render(): void {\n    // Here because AngleSpec does units tranform and label doesn't support specs\n    let angle: number\n    switch (this.model.angle_units) {\n      case \"rad\": {\n        angle = -1 * this.model.angle\n        break\n      }\n      case \"deg\": {\n        angle = -1 * this.model.angle * Math.PI/180.0\n        break\n      }\n      default:\n        throw new Error(\"unreachable\")\n    }\n\n    const panel = this.panel || this.plot_view.frame\n\n    const xscale = this.plot_view.frame.xscales[this.model.x_range_name]\n    const yscale = this.plot_view.frame.yscales[this.model.y_range_name]\n\n    const {x, y} = this.model\n    let sx = this.model.x_units == \"data\" ? xscale.compute(x) : panel.xview.compute(x)\n    let sy = this.model.y_units == \"data\" ? yscale.compute(y) : panel.yview.compute(y)\n\n    sx += this.model.x_offset\n    sy -= this.model.y_offset\n\n    this._css_text(this.layer.ctx, \"\", sx, sy, angle)\n    katex.render(this.model.text, this.el, {displayMode: true})\n  }\n}\n\nexport class LatexLabel extends Label {\n  static init_LatexLabel(): void {\n    this.prototype.default_view = LatexLabelView\n  }\n}\n\"\"\")\n\np = figure(title=\"LaTex Extension Demonstration\", plot_width=800, plot_height=350,\n           background_fill_color=\"#fafafa\")\np.x_range.range_padding = 0\n\nx = np.arange(0.0, 20.0, 0.02)\n\nfor i, n in enumerate([0, 1, 4, 7]):\n    p.line(x, jv(n, x), line_width=3, color=Spectral4[i], alpha=0.8, legend_label=\"\ud835\udf08=%d\" % n)\n\n\ntext = (r\"\\text{Bessel Functions of the First Kind: }\" +\n        r\"J_\\nu = \\sum_{m=0}^{\\infty}\\frac{(-1)^m}{m!\\ \\Gamma(m+\\nu+1)}\" +\n        r\"\\left(\\frac{x}{2}\\right)^{2m+\\nu}\")\nlatex = LatexLabel(text=text,x=4.5, y=250, x_units='data', y_units='screen',\n                   render_mode='css', text_font_size='11px',\n                   background_fill_color=\"white\", border_line_color=\"lightgrey\")\n\np.add_layout(latex)\n\nshow(p)\n", "path": "examples/models/file/latex_extension.py"}], "after_files": [{"content": "\"\"\" The LaTex example was derived from: http://matplotlib.org/users/usetex.html\n\"\"\"\nimport numpy as np\nfrom scipy.special import jv\n\nfrom bokeh.models import Label\nfrom bokeh.palettes import Spectral4\nfrom bokeh.plotting import figure, output_file, show\nfrom bokeh.util.compiler import TypeScript\n\noutput_file('latex_extension.html')\n\nclass LatexLabel(Label):\n    \"\"\"A subclass of `Label` with all of the same class attributes except\n    canvas mode isn't supported and DOM manipulation happens in the TypeScript\n    superclass implementation that requires setting `render_mode='css'`).\n\n    Only the render method of LabelView is overwritten to perform the\n    text -> latex (via katex) conversion\n    \"\"\"\n    __javascript__ = [\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.js\"]\n    __css__ = [\"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css\"]\n    __implementation__ = TypeScript(\"\"\"\nimport {Label, LabelView} from \"models/annotations/label\"\n\ndeclare namespace katex {\n  function render(expression: string, element: HTMLElement, options: {displayMode?: boolean}): void\n}\n\nexport class LatexLabelView extends LabelView {\n  model: LatexLabel\n\n  protected _render(): void {\n    // Here because AngleSpec does units tranform and label doesn't support specs\n    let angle: number\n    switch (this.model.angle_units) {\n      case \"rad\": {\n        angle = -1 * this.model.angle\n        break\n      }\n      case \"deg\": {\n        angle = -1 * this.model.angle * Math.PI/180.0\n        break\n      }\n      default:\n        throw new Error(\"unreachable\")\n    }\n\n    const panel = this.panel || this.plot_view.frame\n\n    const xscale = this.plot_view.frame.xscales[this.model.x_range_name]\n    const yscale = this.plot_view.frame.yscales[this.model.y_range_name]\n\n    const {x, y} = this.model\n    let sx = this.model.x_units == \"data\" ? xscale.compute(x) : panel.xview.compute(x)\n    let sy = this.model.y_units == \"data\" ? yscale.compute(y) : panel.yview.compute(y)\n\n    sx += this.model.x_offset\n    sy -= this.model.y_offset\n\n    this._css_text(this.layer.ctx, \"\", sx, sy, angle)\n    katex.render(this.model.text, this.el!, {displayMode: true})\n  }\n}\n\nexport class LatexLabel extends Label {\n  static init_LatexLabel(): void {\n    this.prototype.default_view = LatexLabelView\n\n    this.override({\n      render_mode: \"css\",\n    })\n  }\n}\n\"\"\")\n\np = figure(title=\"LaTex Extension Demonstration\", plot_width=800, plot_height=350,\n           background_fill_color=\"#fafafa\")\np.x_range.range_padding = 0\n\nx = np.arange(0.0, 20.0, 0.02)\n\nfor i, n in enumerate([0, 1, 4, 7]):\n    p.line(x, jv(n, x), line_width=3, color=Spectral4[i], alpha=0.8, legend_label=\"\ud835\udf08=%d\" % n)\n\n\ntext = (r\"\\text{Bessel Functions of the First Kind: }\" +\n        r\"J_\\nu = \\sum_{m=0}^{\\infty}\\frac{(-1)^m}{m!\\ \\Gamma(m+\\nu+1)}\" +\n        r\"\\left(\\frac{x}{2}\\right)^{2m+\\nu}\")\nlatex = LatexLabel(text=text,x=4.5, y=250, x_units='data', y_units='screen',\n                   render_mode='css', text_font_size='11px',\n                   background_fill_color=\"white\", border_line_color=\"lightgrey\")\n\np.add_layout(latex)\n\nshow(p)\n", "path": "examples/models/file/latex_extension.py"}]}