prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  blending mode update error
  ## 🐛 Bug
  
  When viewing multiple layers with blending, I am experiencing a bug whereby changing the blending mode doesn't result in an immediate update. The update does occur when I change the opacity (at which point is happens immediately). 
  
  ![bug](https://user-images.githubusercontent.com/3387500/55253093-aa80cc00-5211-11e9-828c-686595346b86.gif)
  
  
  ## To Reproduce
  
  Steps to reproduce the behavior:
  
  1. Open the viewer with multiple layers (e.g. `examples/layers.py`)
  2. Reduce the opacity of the top most layer to 0.5
  3. Change the blending mode (e.g. `translucent` -> `opaque`)
  
  ## Expected behavior
  
  The update to what is rendered should happen immediately upon updating the blending mode.
  
  ## Environment
  
   - napari 0.18
   - OS X 10.14.3
   - Python version: 3.7.2
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `napari/layers/_base_layer/_visual_wrapper.py`
  Content:
  ```
  1 # TODO: create & use our own transform class
  2 from vispy.visuals.transforms import STTransform
  3 from vispy.gloo import get_state_presets
  4 from ...util.event import EmitterGroup, Event
  5 
  6 
  7 class VisualWrapper:
  8     """Wrapper around ``vispy.scene.VisualNode`` objects.
  9     Meant to be subclassed.
  10 
  11     "Hidden" properties:
  12         * ``_master_transform``
  13         * ``_order``
  14         * ``_parent``
  15 
  16     Parameters
  17     ----------
  18     central_node : vispy.scene.VisualNode
  19         Central node/control point with which to interact with the visual.
  20         Stored as ``_node``.
  21 
  22     Attributes
  23     ----------
  24     opacity
  25     visible
  26     scale
  27     blending
  28     translate
  29     z_index
  30 
  31     Notes
  32     -----
  33     It is recommended to use the backported ``vispy`` nodes
  34     at ``_vispy.scene.visuals`` for various bug fixes.
  35     """
  36     def __init__(self, central_node):
  37         self._node = central_node
  38         self._blending = 'translucent'
  39         self.events = EmitterGroup(source=self,
  40                                    auto_connect=True,
  41                                    blending=Event,
  42                                    opacity=Event,
  43                                    visible=Event)
  44 
  45     _blending_modes = set(get_state_presets().keys())
  46 
  47     @property
  48     def _master_transform(self):
  49         """vispy.visuals.transforms.STTransform:
  50         Central node's firstmost transform.
  51         """
  52         # whenever a new parent is set, the transform is reset
  53         # to a NullTransform so we reset it here
  54         if not isinstance(self._node.transform, STTransform):
  55             self._node.transform = STTransform()
  56 
  57         return self._node.transform
  58 
  59     @property
  60     def _order(self):
  61         """int: Order in which the visual is drawn in the scenegraph.
  62         Lower values are closer to the viewer.
  63         """
  64         return self._node.order
  65 
  66     @_order.setter
  67     def _order(self, order):
  68         # workaround for opacity (see: #22)
  69         order = -order
  70         self.z_index = order
  71         # end workaround
  72         self._node.order = order
  73 
  74     @property
  75     def _parent(self):
  76         """vispy.scene.Node: Parent node.
  77         """
  78         return self._node.parent
  79 
  80     @_parent.setter
  81     def _parent(self, parent):
  82         self._node.parent = parent
  83 
  84     @property
  85     def opacity(self):
  86         """float: Opacity value between 0.0 and 1.0.
  87         """
  88         return self._node.opacity
  89 
  90     @opacity.setter
  91     def opacity(self, opacity):
  92         if not 0.0 <= opacity <= 1.0:
  93             raise ValueError('opacity must be between 0.0 and 1.0; '
  94                              f'got {opacity}')
  95 
  96         self._node.opacity = opacity
  97         self.events.opacity()
  98 
  99     @property
  100     def blending(self):
  101         """{'opaque', 'translucent', 'additive'}: Blending mode.
  102             Selects a preset blending mode in vispy that determines how
  103             RGB and alpha values get mixed.
  104             'opaque'
  105                 Allows for only the top layer to be visible and corresponds to
  106                 depth_test=True, cull_face=False, blend=False.
  107             'translucent'
  108                 Allows for multiple layers to be blended with different opacity
  109                 and corresponds to depth_test=True, cull_face=False,
  110                 blend=True, blend_func=('src_alpha', 'one_minus_src_alpha').
  111             'additive'
  112                 Allows for multiple layers to be blended together with
  113                 different colors and opacity. Useful for creating overlays. It
  114                 corresponds to depth_test=False, cull_face=False, blend=True,
  115                 blend_func=('src_alpha', 'one').
  116         """
  117         return self._blending
  118 
  119     @blending.setter
  120     def blending(self, blending):
  121         if blending not in self._blending_modes:
  122             raise ValueError('expected one of '
  123                              "{'opaque', 'translucent', 'additive'}; "
  124                              f'got {blending}')
  125         self._node.set_gl_state(blending)
  126         self._blending = blending
  127         self.events.blending()
  128 
  129     @property
  130     def visible(self):
  131         """bool: Whether the visual is currently being displayed.
  132         """
  133         return self._node.visible
  134 
  135     @visible.setter
  136     def visible(self, visibility):
  137         self._node.visible = visibility
  138         self.events.visible()
  139 
  140     @property
  141     def scale(self):
  142         """sequence of float: Scale factors.
  143         """
  144         return self._master_transform.scale
  145 
  146     @scale.setter
  147     def scale(self, scale):
  148         self._master_transform.scale = scale
  149 
  150     @property
  151     def translate(self):
  152         """sequence of float: Translation values.
  153         """
  154         return self._master_transform.translate
  155 
  156     @translate.setter
  157     def translate(self, translate):
  158         self._master_transform.translate = translate
  159 
  160     @property
  161     def z_index(self):
  162         return -self._master_transform.translate[2]
  163 
  164     @z_index.setter
  165     def z_index(self, index):
  166         tr = self._master_transform
  167         tl = tr.translate
  168         tl[2] = -index
  169 
  170         tr.translate = tl
  171
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/napari/layers/_base_layer/_visual_wrapper.py b/napari/layers/_base_layer/_visual_wrapper.py
  --- a/napari/layers/_base_layer/_visual_wrapper.py
  +++ b/napari/layers/_base_layer/_visual_wrapper.py
  @@ -124,6 +124,7 @@
                                f'got {blending}')
           self._node.set_gl_state(blending)
           self._blending = blending
  +        self._node.update()
           self.events.blending()
   
       @property
  
verification_info: {"golden_diff": "diff --git a/napari/layers/_base_layer/_visual_wrapper.py b/napari/layers/_base_layer/_visual_wrapper.py\n--- a/napari/layers/_base_layer/_visual_wrapper.py\n+++ b/napari/layers/_base_layer/_visual_wrapper.py\n@@ -124,6 +124,7 @@\n                              f'got {blending}')\n         self._node.set_gl_state(blending)\n         self._blending = blending\n+        self._node.update()\n         self.events.blending()\n \n     @property\n", "issue": "blending mode update error\n## \ud83d\udc1b Bug\r\n\r\nWhen viewing multiple layers with blending, I am experiencing a bug whereby changing the blending mode doesn't result in an immediate update. The update does occur when I change the opacity (at which point is happens immediately). \r\n\r\n![bug](https://user-images.githubusercontent.com/3387500/55253093-aa80cc00-5211-11e9-828c-686595346b86.gif)\r\n\r\n\r\n## To Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Open the viewer with multiple layers (e.g. `examples/layers.py`)\r\n2. Reduce the opacity of the top most layer to 0.5\r\n3. Change the blending mode (e.g. `translucent` -> `opaque`)\r\n\r\n## Expected behavior\r\n\r\nThe update to what is rendered should happen immediately upon updating the blending mode.\r\n\r\n## Environment\r\n\r\n - napari 0.18\r\n - OS X 10.14.3\r\n - Python version: 3.7.2\r\n\n", "before_files": [{"content": "# TODO: create & use our own transform class\nfrom vispy.visuals.transforms import STTransform\nfrom vispy.gloo import get_state_presets\nfrom ...util.event import EmitterGroup, Event\n\n\nclass VisualWrapper:\n    \"\"\"Wrapper around ``vispy.scene.VisualNode`` objects.\n    Meant to be subclassed.\n\n    \"Hidden\" properties:\n        * ``_master_transform``\n        * ``_order``\n        * ``_parent``\n\n    Parameters\n    ----------\n    central_node : vispy.scene.VisualNode\n        Central node/control point with which to interact with the visual.\n        Stored as ``_node``.\n\n    Attributes\n    ----------\n    opacity\n    visible\n    scale\n    blending\n    translate\n    z_index\n\n    Notes\n    -----\n    It is recommended to use the backported ``vispy`` nodes\n    at ``_vispy.scene.visuals`` for various bug fixes.\n    \"\"\"\n    def __init__(self, central_node):\n        self._node = central_node\n        self._blending = 'translucent'\n        self.events = EmitterGroup(source=self,\n                                   auto_connect=True,\n                                   blending=Event,\n                                   opacity=Event,\n                                   visible=Event)\n\n    _blending_modes = set(get_state_presets().keys())\n\n    @property\n    def _master_transform(self):\n        \"\"\"vispy.visuals.transforms.STTransform:\n        Central node's firstmost transform.\n        \"\"\"\n        # whenever a new parent is set, the transform is reset\n        # to a NullTransform so we reset it here\n        if not isinstance(self._node.transform, STTransform):\n            self._node.transform = STTransform()\n\n        return self._node.transform\n\n    @property\n    def _order(self):\n        \"\"\"int: Order in which the visual is drawn in the scenegraph.\n        Lower values are closer to the viewer.\n        \"\"\"\n        return self._node.order\n\n    @_order.setter\n    def _order(self, order):\n        # workaround for opacity (see: #22)\n        order = -order\n        self.z_index = order\n        # end workaround\n        self._node.order = order\n\n    @property\n    def _parent(self):\n        \"\"\"vispy.scene.Node: Parent node.\n        \"\"\"\n        return self._node.parent\n\n    @_parent.setter\n    def _parent(self, parent):\n        self._node.parent = parent\n\n    @property\n    def opacity(self):\n        \"\"\"float: Opacity value between 0.0 and 1.0.\n        \"\"\"\n        return self._node.opacity\n\n    @opacity.setter\n    def opacity(self, opacity):\n        if not 0.0 <= opacity <= 1.0:\n            raise ValueError('opacity must be between 0.0 and 1.0; '\n                             f'got {opacity}')\n\n        self._node.opacity = opacity\n        self.events.opacity()\n\n    @property\n    def blending(self):\n        \"\"\"{'opaque', 'translucent', 'additive'}: Blending mode.\n            Selects a preset blending mode in vispy that determines how\n            RGB and alpha values get mixed.\n            'opaque'\n                Allows for only the top layer to be visible and corresponds to\n                depth_test=True, cull_face=False, blend=False.\n            'translucent'\n                Allows for multiple layers to be blended with different opacity\n                and corresponds to depth_test=True, cull_face=False,\n                blend=True, blend_func=('src_alpha', 'one_minus_src_alpha').\n            'additive'\n                Allows for multiple layers to be blended together with\n                different colors and opacity. Useful for creating overlays. It\n                corresponds to depth_test=False, cull_face=False, blend=True,\n                blend_func=('src_alpha', 'one').\n        \"\"\"\n        return self._blending\n\n    @blending.setter\n    def blending(self, blending):\n        if blending not in self._blending_modes:\n            raise ValueError('expected one of '\n                             \"{'opaque', 'translucent', 'additive'}; \"\n                             f'got {blending}')\n        self._node.set_gl_state(blending)\n        self._blending = blending\n        self.events.blending()\n\n    @property\n    def visible(self):\n        \"\"\"bool: Whether the visual is currently being displayed.\n        \"\"\"\n        return self._node.visible\n\n    @visible.setter\n    def visible(self, visibility):\n        self._node.visible = visibility\n        self.events.visible()\n\n    @property\n    def scale(self):\n        \"\"\"sequence of float: Scale factors.\n        \"\"\"\n        return self._master_transform.scale\n\n    @scale.setter\n    def scale(self, scale):\n        self._master_transform.scale = scale\n\n    @property\n    def translate(self):\n        \"\"\"sequence of float: Translation values.\n        \"\"\"\n        return self._master_transform.translate\n\n    @translate.setter\n    def translate(self, translate):\n        self._master_transform.translate = translate\n\n    @property\n    def z_index(self):\n        return -self._master_transform.translate[2]\n\n    @z_index.setter\n    def z_index(self, index):\n        tr = self._master_transform\n        tl = tr.translate\n        tl[2] = -index\n\n        tr.translate = tl\n", "path": "napari/layers/_base_layer/_visual_wrapper.py"}], "after_files": [{"content": "# TODO: create & use our own transform class\nfrom vispy.visuals.transforms import STTransform\nfrom vispy.gloo import get_state_presets\nfrom ...util.event import EmitterGroup, Event\n\n\nclass VisualWrapper:\n    \"\"\"Wrapper around ``vispy.scene.VisualNode`` objects.\n    Meant to be subclassed.\n\n    \"Hidden\" properties:\n        * ``_master_transform``\n        * ``_order``\n        * ``_parent``\n\n    Parameters\n    ----------\n    central_node : vispy.scene.VisualNode\n        Central node/control point with which to interact with the visual.\n        Stored as ``_node``.\n\n    Attributes\n    ----------\n    opacity\n    visible\n    scale\n    blending\n    translate\n    z_index\n\n    Notes\n    -----\n    It is recommended to use the backported ``vispy`` nodes\n    at ``_vispy.scene.visuals`` for various bug fixes.\n    \"\"\"\n    def __init__(self, central_node):\n        self._node = central_node\n        self._blending = 'translucent'\n        self.events = EmitterGroup(source=self,\n                                   auto_connect=True,\n                                   blending=Event,\n                                   opacity=Event,\n                                   visible=Event)\n\n    _blending_modes = set(get_state_presets().keys())\n\n    @property\n    def _master_transform(self):\n        \"\"\"vispy.visuals.transforms.STTransform:\n        Central node's firstmost transform.\n        \"\"\"\n        # whenever a new parent is set, the transform is reset\n        # to a NullTransform so we reset it here\n        if not isinstance(self._node.transform, STTransform):\n            self._node.transform = STTransform()\n\n        return self._node.transform\n\n    @property\n    def _order(self):\n        \"\"\"int: Order in which the visual is drawn in the scenegraph.\n        Lower values are closer to the viewer.\n        \"\"\"\n        return self._node.order\n\n    @_order.setter\n    def _order(self, order):\n        # workaround for opacity (see: #22)\n        order = -order\n        self.z_index = order\n        # end workaround\n        self._node.order = order\n\n    @property\n    def _parent(self):\n        \"\"\"vispy.scene.Node: Parent node.\n        \"\"\"\n        return self._node.parent\n\n    @_parent.setter\n    def _parent(self, parent):\n        self._node.parent = parent\n\n    @property\n    def opacity(self):\n        \"\"\"float: Opacity value between 0.0 and 1.0.\n        \"\"\"\n        return self._node.opacity\n\n    @opacity.setter\n    def opacity(self, opacity):\n        if not 0.0 <= opacity <= 1.0:\n            raise ValueError('opacity must be between 0.0 and 1.0; '\n                             f'got {opacity}')\n\n        self._node.opacity = opacity\n        self.events.opacity()\n\n    @property\n    def blending(self):\n        \"\"\"{'opaque', 'translucent', 'additive'}: Blending mode.\n            Selects a preset blending mode in vispy that determines how\n            RGB and alpha values get mixed.\n            'opaque'\n                Allows for only the top layer to be visible and corresponds to\n                depth_test=True, cull_face=False, blend=False.\n            'translucent'\n                Allows for multiple layers to be blended with different opacity\n                and corresponds to depth_test=True, cull_face=False,\n                blend=True, blend_func=('src_alpha', 'one_minus_src_alpha').\n            'additive'\n                Allows for multiple layers to be blended together with\n                different colors and opacity. Useful for creating overlays. It\n                corresponds to depth_test=False, cull_face=False, blend=True,\n                blend_func=('src_alpha', 'one').\n        \"\"\"\n        return self._blending\n\n    @blending.setter\n    def blending(self, blending):\n        if blending not in self._blending_modes:\n            raise ValueError('expected one of '\n                             \"{'opaque', 'translucent', 'additive'}; \"\n                             f'got {blending}')\n        self._node.set_gl_state(blending)\n        self._blending = blending\n        self._node.update()\n        self.events.blending()\n\n    @property\n    def visible(self):\n        \"\"\"bool: Whether the visual is currently being displayed.\n        \"\"\"\n        return self._node.visible\n\n    @visible.setter\n    def visible(self, visibility):\n        self._node.visible = visibility\n        self.events.visible()\n\n    @property\n    def scale(self):\n        \"\"\"sequence of float: Scale factors.\n        \"\"\"\n        return self._master_transform.scale\n\n    @scale.setter\n    def scale(self, scale):\n        self._master_transform.scale = scale\n\n    @property\n    def translate(self):\n        \"\"\"sequence of float: Translation values.\n        \"\"\"\n        return self._master_transform.translate\n\n    @translate.setter\n    def translate(self, translate):\n        self._master_transform.translate = translate\n\n    @property\n    def z_index(self):\n        return -self._master_transform.translate[2]\n\n    @z_index.setter\n    def z_index(self, index):\n        tr = self._master_transform\n        tl = tr.translate\n        tl[2] = -index\n\n        tr.translate = tl\n", "path": "napari/layers/_base_layer/_visual_wrapper.py"}]}