We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Touchtracer - delay when trying to draw
I don't even see it if I don't look close, but if I'm right, the thing that's mentioned in [this question](http://stackoverflow.com/q/37933920/5994041) is in fact a delay I see here. If not, there's a delay anyway. It's like there is an invisible(because bg isn't only single color) brush covering the touch - such thing you can see even in Paint as it shows you where the brush actually is.

Touchtracer seems to catch every touch, yet something slips and is displayed hm... after there's enough items in a list or something? E.g. it won't draw until there's at least 3-4+ touches in let's say `touches = []` so that a line could be drawn? Even if, you can construct a line with two points, but I see that more than two touches are not present when I drag the mouse until another part is drawn(see the red circle). This thing is present even with master and from each side(it's not an issue with misplaced touch coords).

![image](https://cloud.githubusercontent.com/assets/8825439/16315583/233d8a16-3983-11e6-9564-79acdd90d607.png)


--- 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/demo/touchtracer/main.py`
Content:
```
1 '''
2 Touch Tracer Line Drawing Demonstration
3 =======================================
4 
5 This demonstrates tracking each touch registered to a device. You should
6 see a basic background image. When you press and hold the mouse, you
7 should see cross-hairs with the coordinates written next to them. As
8 you drag, it leaves a trail. Additional information, like pressure,
9 will be shown if they are in your device's touch.profile.
10 
11 This program specifies an icon, the file icon.png, in its App subclass.
12 It also uses the particle.png file as the source for drawing the trails which
13 are white on transparent. The file touchtracer.kv describes the application.
14 
15 The file android.txt is used to package the application for use with the
16 Kivy Launcher Android application. For Android devices, you can
17 copy/paste this directory into /sdcard/kivy/touchtracer on your Android device.
18 
19 '''
20 __version__ = '1.0'
21 
22 import kivy
23 kivy.require('1.0.6')
24 
25 from kivy.app import App
26 from kivy.uix.floatlayout import FloatLayout
27 from kivy.uix.label import Label
28 from kivy.graphics import Color, Rectangle, Point, GraphicException
29 from random import random
30 from math import sqrt
31 
32 
33 def calculate_points(x1, y1, x2, y2, steps=5):
34     dx = x2 - x1
35     dy = y2 - y1
36     dist = sqrt(dx * dx + dy * dy)
37     if dist < steps:
38         return None
39     o = []
40     m = dist / steps
41     for i in range(1, int(m)):
42         mi = i / m
43         lastx = x1 + dx * mi
44         lasty = y1 + dy * mi
45         o.extend([lastx, lasty])
46     return o
47 
48 
49 class Touchtracer(FloatLayout):
50 
51     def on_touch_down(self, touch):
52         win = self.get_parent_window()
53         ud = touch.ud
54         ud['group'] = g = str(touch.uid)
55         pointsize = 5
56         if 'pressure' in touch.profile:
57             ud['pressure'] = touch.pressure
58             pointsize = (touch.pressure * 100000) ** 2
59         ud['color'] = random()
60 
61         with self.canvas:
62             Color(ud['color'], 1, 1, mode='hsv', group=g)
63             ud['lines'] = [
64                 Rectangle(pos=(touch.x, 0), size=(1, win.height), group=g),
65                 Rectangle(pos=(0, touch.y), size=(win.width, 1), group=g),
66                 Point(points=(touch.x, touch.y), source='particle.png',
67                       pointsize=pointsize, group=g)]
68 
69         ud['label'] = Label(size_hint=(None, None))
70         self.update_touch_label(ud['label'], touch)
71         self.add_widget(ud['label'])
72         touch.grab(self)
73         return True
74 
75     def on_touch_move(self, touch):
76         if touch.grab_current is not self:
77             return
78         ud = touch.ud
79         ud['lines'][0].pos = touch.x, 0
80         ud['lines'][1].pos = 0, touch.y
81 
82         index = -1
83 
84         while True:
85             try:
86                 points = ud['lines'][index].points
87                 oldx, oldy = points[-2], points[-1]
88                 break
89             except:
90                 index -= 1
91 
92         points = calculate_points(oldx, oldy, touch.x, touch.y)
93 
94         # if pressure changed create a new point instruction
95         if 'pressure' in ud:
96             if not .95 < (touch.pressure / ud['pressure']) < 1.05:
97                 g = ud['group']
98                 pointsize = (touch.pressure * 100000) ** 2
99                 with self.canvas:
100                     Color(ud['color'], 1, 1, mode='hsv', group=g)
101                     ud['lines'].append(
102                         Point(points=(), source='particle.png',
103                               pointsize=pointsize, group=g))
104 
105         if points:
106             try:
107                 lp = ud['lines'][-1].add_point
108                 for idx in range(0, len(points), 2):
109                     lp(points[idx], points[idx + 1])
110             except GraphicException:
111                 pass
112 
113         ud['label'].pos = touch.pos
114         import time
115         t = int(time.time())
116         if t not in ud:
117             ud[t] = 1
118         else:
119             ud[t] += 1
120         self.update_touch_label(ud['label'], touch)
121 
122     def on_touch_up(self, touch):
123         if touch.grab_current is not self:
124             return
125         touch.ungrab(self)
126         ud = touch.ud
127         self.canvas.remove_group(ud['group'])
128         self.remove_widget(ud['label'])
129 
130     def update_touch_label(self, label, touch):
131         label.text = 'ID: %s\nPos: (%d, %d)\nClass: %s' % (
132             touch.id, touch.x, touch.y, touch.__class__.__name__)
133         label.texture_update()
134         label.pos = touch.pos
135         label.size = label.texture_size[0] + 20, label.texture_size[1] + 20
136 
137 
138 class TouchtracerApp(App):
139     title = 'Touchtracer'
140     icon = 'icon.png'
141 
142     def build(self):
143         return Touchtracer()
144 
145     def on_pause(self):
146         return True
147 
148 if __name__ == '__main__':
149     TouchtracerApp().run()
150
```
--- 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/demo/touchtracer/main.py b/examples/demo/touchtracer/main.py
--- a/examples/demo/touchtracer/main.py
+++ b/examples/demo/touchtracer/main.py
@@ -8,6 +8,12 @@
 you drag, it leaves a trail. Additional information, like pressure,
 will be shown if they are in your device's touch.profile.
 
+.. note::
+
+   A function `calculate_points` handling the points which will be drawn
+   has by default implemented a delay of 5 steps. To get more precise visual
+   results lower the value of the optional keyword argument `steps`.
+
 This program specifies an icon, the file icon.png, in its App subclass.
 It also uses the particle.png file as the source for drawing the trails which
 are white on transparent. The file touchtracer.kv describes the application.

{"golden_diff": "diff --git a/examples/demo/touchtracer/main.py b/examples/demo/touchtracer/main.py\n--- a/examples/demo/touchtracer/main.py\n+++ b/examples/demo/touchtracer/main.py\n@@ -8,6 +8,12 @@\n you drag, it leaves a trail. Additional information, like pressure,\n will be shown if they are in your device's touch.profile.\n \n+.. note::\n+\n+   A function `calculate_points` handling the points which will be drawn\n+   has by default implemented a delay of 5 steps. To get more precise visual\n+   results lower the value of the optional keyword argument `steps`.\n+\n This program specifies an icon, the file icon.png, in its App subclass.\n It also uses the particle.png file as the source for drawing the trails which\n are white on transparent. The file touchtracer.kv describes the application.\n", "issue": "Touchtracer - delay when trying to draw\nI don't even see it if I don't look close, but if I'm right, the thing that's mentioned in [this question](http://stackoverflow.com/q/37933920/5994041) is in fact a delay I see here. If not, there's a delay anyway. It's like there is an invisible(because bg isn't only single color) brush covering the touch - such thing you can see even in Paint as it shows you where the brush actually is.\n\nTouchtracer seems to catch every touch, yet something slips and is displayed hm... after there's enough items in a list or something? E.g. it won't draw until there's at least 3-4+ touches in let's say `touches = []` so that a line could be drawn? Even if, you can construct a line with two points, but I see that more than two touches are not present when I drag the mouse until another part is drawn(see the red circle). This thing is present even with master and from each side(it's not an issue with misplaced touch coords).\n\n![image](https://cloud.githubusercontent.com/assets/8825439/16315583/233d8a16-3983-11e6-9564-79acdd90d607.png)\n\n", "before_files": [{"content": "'''\nTouch Tracer Line Drawing Demonstration\n=======================================\n\nThis demonstrates tracking each touch registered to a device. You should\nsee a basic background image. When you press and hold the mouse, you\nshould see cross-hairs with the coordinates written next to them. As\nyou drag, it leaves a trail. Additional information, like pressure,\nwill be shown if they are in your device's touch.profile.\n\nThis program specifies an icon, the file icon.png, in its App subclass.\nIt also uses the particle.png file as the source for drawing the trails which\nare white on transparent. The file touchtracer.kv describes the application.\n\nThe file android.txt is used to package the application for use with the\nKivy Launcher Android application. For Android devices, you can\ncopy/paste this directory into /sdcard/kivy/touchtracer on your Android device.\n\n'''\n__version__ = '1.0'\n\nimport kivy\nkivy.require('1.0.6')\n\nfrom kivy.app import App\nfrom kivy.uix.floatlayout import FloatLayout\nfrom kivy.uix.label import Label\nfrom kivy.graphics import Color, Rectangle, Point, GraphicException\nfrom random import random\nfrom math import sqrt\n\n\ndef calculate_points(x1, y1, x2, y2, steps=5):\n    dx = x2 - x1\n    dy = y2 - y1\n    dist = sqrt(dx * dx + dy * dy)\n    if dist < steps:\n        return None\n    o = []\n    m = dist / steps\n    for i in range(1, int(m)):\n        mi = i / m\n        lastx = x1 + dx * mi\n        lasty = y1 + dy * mi\n        o.extend([lastx, lasty])\n    return o\n\n\nclass Touchtracer(FloatLayout):\n\n    def on_touch_down(self, touch):\n        win = self.get_parent_window()\n        ud = touch.ud\n        ud['group'] = g = str(touch.uid)\n        pointsize = 5\n        if 'pressure' in touch.profile:\n            ud['pressure'] = touch.pressure\n            pointsize = (touch.pressure * 100000) ** 2\n        ud['color'] = random()\n\n        with self.canvas:\n            Color(ud['color'], 1, 1, mode='hsv', group=g)\n            ud['lines'] = [\n                Rectangle(pos=(touch.x, 0), size=(1, win.height), group=g),\n                Rectangle(pos=(0, touch.y), size=(win.width, 1), group=g),\n                Point(points=(touch.x, touch.y), source='particle.png',\n                      pointsize=pointsize, group=g)]\n\n        ud['label'] = Label(size_hint=(None, None))\n        self.update_touch_label(ud['label'], touch)\n        self.add_widget(ud['label'])\n        touch.grab(self)\n        return True\n\n    def on_touch_move(self, touch):\n        if touch.grab_current is not self:\n            return\n        ud = touch.ud\n        ud['lines'][0].pos = touch.x, 0\n        ud['lines'][1].pos = 0, touch.y\n\n        index = -1\n\n        while True:\n            try:\n                points = ud['lines'][index].points\n                oldx, oldy = points[-2], points[-1]\n                break\n            except:\n                index -= 1\n\n        points = calculate_points(oldx, oldy, touch.x, touch.y)\n\n        # if pressure changed create a new point instruction\n        if 'pressure' in ud:\n            if not .95 < (touch.pressure / ud['pressure']) < 1.05:\n                g = ud['group']\n                pointsize = (touch.pressure * 100000) ** 2\n                with self.canvas:\n                    Color(ud['color'], 1, 1, mode='hsv', group=g)\n                    ud['lines'].append(\n                        Point(points=(), source='particle.png',\n                              pointsize=pointsize, group=g))\n\n        if points:\n            try:\n                lp = ud['lines'][-1].add_point\n                for idx in range(0, len(points), 2):\n                    lp(points[idx], points[idx + 1])\n            except GraphicException:\n                pass\n\n        ud['label'].pos = touch.pos\n        import time\n        t = int(time.time())\n        if t not in ud:\n            ud[t] = 1\n        else:\n            ud[t] += 1\n        self.update_touch_label(ud['label'], touch)\n\n    def on_touch_up(self, touch):\n        if touch.grab_current is not self:\n            return\n        touch.ungrab(self)\n        ud = touch.ud\n        self.canvas.remove_group(ud['group'])\n        self.remove_widget(ud['label'])\n\n    def update_touch_label(self, label, touch):\n        label.text = 'ID: %s\\nPos: (%d, %d)\\nClass: %s' % (\n            touch.id, touch.x, touch.y, touch.__class__.__name__)\n        label.texture_update()\n        label.pos = touch.pos\n        label.size = label.texture_size[0] + 20, label.texture_size[1] + 20\n\n\nclass TouchtracerApp(App):\n    title = 'Touchtracer'\n    icon = 'icon.png'\n\n    def build(self):\n        return Touchtracer()\n\n    def on_pause(self):\n        return True\n\nif __name__ == '__main__':\n    TouchtracerApp().run()\n", "path": "examples/demo/touchtracer/main.py"}], "after_files": [{"content": "'''\nTouch Tracer Line Drawing Demonstration\n=======================================\n\nThis demonstrates tracking each touch registered to a device. You should\nsee a basic background image. When you press and hold the mouse, you\nshould see cross-hairs with the coordinates written next to them. As\nyou drag, it leaves a trail. Additional information, like pressure,\nwill be shown if they are in your device's touch.profile.\n\n.. note::\n\n   A function `calculate_points` handling the points which will be drawn\n   has by default implemented a delay of 5 steps. To get more precise visual\n   results lower the value of the optional keyword argument `steps`.\n\nThis program specifies an icon, the file icon.png, in its App subclass.\nIt also uses the particle.png file as the source for drawing the trails which\nare white on transparent. The file touchtracer.kv describes the application.\n\nThe file android.txt is used to package the application for use with the\nKivy Launcher Android application. For Android devices, you can\ncopy/paste this directory into /sdcard/kivy/touchtracer on your Android device.\n\n'''\n__version__ = '1.0'\n\nimport kivy\nkivy.require('1.0.6')\n\nfrom kivy.app import App\nfrom kivy.uix.floatlayout import FloatLayout\nfrom kivy.uix.label import Label\nfrom kivy.graphics import Color, Rectangle, Point, GraphicException\nfrom random import random\nfrom math import sqrt\n\n\ndef calculate_points(x1, y1, x2, y2, steps=5):\n    dx = x2 - x1\n    dy = y2 - y1\n    dist = sqrt(dx * dx + dy * dy)\n    if dist < steps:\n        return None\n    o = []\n    m = dist / steps\n    for i in range(1, int(m)):\n        mi = i / m\n        lastx = x1 + dx * mi\n        lasty = y1 + dy * mi\n        o.extend([lastx, lasty])\n    return o\n\n\nclass Touchtracer(FloatLayout):\n\n    def on_touch_down(self, touch):\n        win = self.get_parent_window()\n        ud = touch.ud\n        ud['group'] = g = str(touch.uid)\n        pointsize = 5\n        if 'pressure' in touch.profile:\n            ud['pressure'] = touch.pressure\n            pointsize = (touch.pressure * 100000) ** 2\n        ud['color'] = random()\n\n        with self.canvas:\n            Color(ud['color'], 1, 1, mode='hsv', group=g)\n            ud['lines'] = [\n                Rectangle(pos=(touch.x, 0), size=(1, win.height), group=g),\n                Rectangle(pos=(0, touch.y), size=(win.width, 1), group=g),\n                Point(points=(touch.x, touch.y), source='particle.png',\n                      pointsize=pointsize, group=g)]\n\n        ud['label'] = Label(size_hint=(None, None))\n        self.update_touch_label(ud['label'], touch)\n        self.add_widget(ud['label'])\n        touch.grab(self)\n        return True\n\n    def on_touch_move(self, touch):\n        if touch.grab_current is not self:\n            return\n        ud = touch.ud\n        ud['lines'][0].pos = touch.x, 0\n        ud['lines'][1].pos = 0, touch.y\n\n        index = -1\n\n        while True:\n            try:\n                points = ud['lines'][index].points\n                oldx, oldy = points[-2], points[-1]\n                break\n            except:\n                index -= 1\n\n        points = calculate_points(oldx, oldy, touch.x, touch.y)\n\n        # if pressure changed create a new point instruction\n        if 'pressure' in ud:\n            if not .95 < (touch.pressure / ud['pressure']) < 1.05:\n                g = ud['group']\n                pointsize = (touch.pressure * 100000) ** 2\n                with self.canvas:\n                    Color(ud['color'], 1, 1, mode='hsv', group=g)\n                    ud['lines'].append(\n                        Point(points=(), source='particle.png',\n                              pointsize=pointsize, group=g))\n\n        if points:\n            try:\n                lp = ud['lines'][-1].add_point\n                for idx in range(0, len(points), 2):\n                    lp(points[idx], points[idx + 1])\n            except GraphicException:\n                pass\n\n        ud['label'].pos = touch.pos\n        import time\n        t = int(time.time())\n        if t not in ud:\n            ud[t] = 1\n        else:\n            ud[t] += 1\n        self.update_touch_label(ud['label'], touch)\n\n    def on_touch_up(self, touch):\n        if touch.grab_current is not self:\n            return\n        touch.ungrab(self)\n        ud = touch.ud\n        self.canvas.remove_group(ud['group'])\n        self.remove_widget(ud['label'])\n\n    def update_touch_label(self, label, touch):\n        label.text = 'ID: %s\\nPos: (%d, %d)\\nClass: %s' % (\n            touch.id, touch.x, touch.y, touch.__class__.__name__)\n        label.texture_update()\n        label.pos = touch.pos\n        label.size = label.texture_size[0] + 20, label.texture_size[1] + 20\n\n\nclass TouchtracerApp(App):\n    title = 'Touchtracer'\n    icon = 'icon.png'\n\n    def build(self):\n        return Touchtracer()\n\n    def on_pause(self):\n        return True\n\nif __name__ == '__main__':\n    TouchtracerApp().run()\n", "path": "examples/demo/touchtracer/main.py"}]}