internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: PaddlePaddle/PaddleOCR

Issue:
win10 训练中断
win10 Cuda11.0 训练icdar2015 检测，减小     batch_size，num_workers还是到
**eval model** 时候中断？？？？

![image](https://user-images.githubusercontent.com/68001817/116015443-d3335400-a66b-11eb-8192-18745b5305e4.png)
![image](https://user-images.githubusercontent.com/68001817/116017716-f3b2dc80-a672-11eb-83c7-3c86f19f27ae.png)



Discussion:
把这里改成`if idx >= len(valid_dataloader) -1: `试下


https://github.com/PaddlePaddle/PaddleOCR/blob/db37ba33103f25607bc2b0004857378e7e786ca0/tools/program.py#L339

Resolving patch:
diff --git a/tools/program.py b/tools/program.py
--- a/tools/program.py
+++ b/tools/program.py
@@ -18,6 +18,7 @@
 
 import os
 import sys
+import platform
 import yaml
 import time
 import shutil
@@ -333,8 +334,10 @@ def eval(model, valid_dataloader, post_process_class, eval_class,
         total_frame = 0.0
         total_time = 0.0
         pbar = tqdm(total=len(valid_dataloader), desc='eval model:')
+        max_iter = len(valid_dataloader) - 1 if platform.system(
+        ) == "Windows" else len(valid_dataloader)
         for idx, batch in enumerate(valid_dataloader):
-            if idx >= len(valid_dataloader):
+            if idx >= max_iter:
                 break
             images = batch[0]
             start = time.time()


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
识别模型处理中文时的问题
尝鲜装了最新的版本，发现训练模型和预测模型差异很大，找了半天问题发现又是[这个问题](https://github.com/PaddlePaddle/PaddleOCR/issues/214#issuecomment-645346661)（其实是忘了自己踩过的坑，以为修复了）

因此就想问问能不能把predict_rec和infer_rec文件里的代码同步下？（指处理当rec_char_type= "ch" 的情况下）看到论坛里不少人都有这个问题了，而且是**从去年到现在**。都过去这么久了真的想吐槽吐槽


Discussion:

Resolving patch:
diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py
--- a/tools/infer/predict_rec.py
+++ b/tools/infer/predict_rec.py
@@ -88,8 +88,8 @@ def __init__(self, args):
     def resize_norm_img(self, img, max_wh_ratio):
         imgC, imgH, imgW = self.rec_image_shape
         assert imgC == img.shape[2]
-        if self.character_type == "ch":
-            imgW = int((32 * max_wh_ratio))
+        max_wh_ratio = max(max_wh_ratio, imgW / imgH)
+        imgW = int((32 * max_wh_ratio))
         h, w = img.shape[:2]
         ratio = w / float(h)
         if math.ceil(imgH * ratio) > imgW:


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
Windows下， OCR识别报错-- 'env' 不是内部或外部命令，也不是可运行的程序或批处理文件
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

- 系统环境/System Environment：Windows10
- 版本号/Version：Paddle：2.3  PaddleOCR：2.3.0.1 
-  问题相关组件/Related components： ppocr
- 运行指令/Command Code：
- ![QQ图片20211227103121](https://user-images.githubusercontent.com/3079297/147428430-1e61ca3e-c4ce-4c1e-8095-7ec327592752.jpg)
- 完整报错/Complete Error Message：
![QQ图片20211226232206](https://user-images.githubusercontent.com/3079297/147428471-03f24025-8077-4491-883e-77b7ee20326a.jpg)


应该是一下代码引起：
PaddleOCR/tools/infer/utility.py  Line#315
```
def get_infer_gpuid():
    if not paddle.fluid.core.is_compiled_with_rocm():
        cmd = "env | grep CUDA_VISIBLE_DEVICES"
    else:
        cmd = "env | grep HIP_VISIBLE_DEVICES"
    env_cuda = os.popen(cmd).readlines()
```

直接将代码替换为
```
def get_infer_gpuid():
    return 0
```
可临时解决.


Discussion:

Resolving patch:
diff --git a/tools/infer/utility.py b/tools/infer/utility.py
--- a/tools/infer/utility.py
+++ b/tools/infer/utility.py
@@ -313,6 +313,11 @@ def create_predictor(args, mode, logger):
 
 
 def get_infer_gpuid():
+    if os.name == 'nt':
+        try:
+            return int(os.environ['CUDA_VISIBLE_DEVICES'].split(',')[0])
+        except KeyError:
+            return 0
     if not paddle.fluid.core.is_compiled_with_rocm():
         cmd = "env | grep CUDA_VISIBLE_DEVICES"
     else:


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
pdserver pipeline模式 v3版本文字识别准确率问题

pdserver pipeline模式 v3版本文字识别准确率比v2版本下降很多，使用的启动脚本和预测脚本都和V2版本相同，观察了一下很多特殊字符例如-这种都检测不出来，是哪里有配置需要改动吗


Discussion:
收到反馈~ 方便提供一张测试图片吗？ 我们排查下问题
> 
这张图片，-15.45,-457.38前面的负号识别不出来
![80C46FFDE1C61A5F07B8254B5DF4437D_IMAGE](https://user-images.githubusercontent.com/26426479/171311483-d67c4816-f72e-4bf1-a26c-ef305e01dc5e.jpg)



Resolving patch:
diff --git a/deploy/pdserving/ocr_reader.py b/deploy/pdserving/ocr_reader.py
--- a/deploy/pdserving/ocr_reader.py
+++ b/deploy/pdserving/ocr_reader.py
@@ -339,7 +339,7 @@ def get_beg_end_flag_idx(self, beg_or_end):
 class OCRReader(object):
     def __init__(self,
                  algorithm="CRNN",
-                 image_shape=[3, 32, 320],
+                 image_shape=[3, 48, 320],
                  char_type="ch",
                  batch_num=1,
                  char_dict_path="./ppocr_keys_v1.txt"):
@@ -356,7 +356,7 @@ def __init__(self,
     def resize_norm_img(self, img, max_wh_ratio):
         imgC, imgH, imgW = self.rec_image_shape
         if self.character_type == "ch":
-            imgW = int(32 * max_wh_ratio)
+            imgW = int(imgH * max_wh_ratio)
         h = img.shape[0]
         w = img.shape[1]
         ratio = w / float(h)
@@ -377,7 +377,7 @@ def resize_norm_img(self, img, max_wh_ratio):
     def preprocess(self, img_list):
         img_num = len(img_list)
         norm_img_batch = []
-        max_wh_ratio = 0
+        max_wh_ratio = 320/48.
         for ino in range(img_num):
             h, w = img_list[ino].shape[0:2]
             wh_ratio = w * 1.0 / h
diff --git a/deploy/pdserving/web_service.py b/deploy/pdserving/web_service.py
--- a/deploy/pdserving/web_service.py
+++ b/deploy/pdserving/web_service.py
@@ -63,7 +63,6 @@ def postprocess(self, input_dicts, fetch_dict, data_id, log_id):
         dt_boxes_list = self.post_func(det_out, [ratio_list])
         dt_boxes = self.filter_func(dt_boxes_list[0], [self.ori_h, self.ori_w])
         out_dict = {"dt_boxes": dt_boxes, "image": self.raw_im}
-
         return out_dict, None, ""
 
 
@@ -86,7 +85,7 @@ def preprocess(self, input_dicts, data_id, log_id):
         dt_boxes = copy.deepcopy(self.dt_list)
         feed_list = []
         img_list = []
-        max_wh_ratio = 0
+        max_wh_ratio = 320/48.
         ## Many mini-batchs, the type of feed_data is list.
         max_batch_size = 6  # len(dt_boxes)
 
@@ -150,7 +149,8 @@ def postprocess(self, input_dicts, fetch_data, data_id, log_id):
         for i in range(dt_num):
             text = rec_list[i]
             dt_box = self.dt_list[i]
-            result_list.append([text, dt_box.tolist()])
+            if text[1] >= 0.5:
+                result_list.append([text, dt_box.tolist()])
         res = {"result": str(result_list)}
         return res, None, ""
 


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
PaddleOCR(use_onnx=True) will try to download wrong model file
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

- 系统环境/System Environment：MacOS 12.4
- 版本号/Version：Paddle：2.3.1  PaddleOCR：2.6 问题相关组件/Related components：PaddleOCR python class
- 运行指令/Command Code：
```python
PaddleOCR(use_onnx=True, det_model_dir=os.path.expanduser("~/.paddleocr/onnx/ch_PP-OCRv3_det_infer.onnx"),
          rec_model_dir=os.path.expanduser("~/.paddleocr/onnx/ch_PP-OCRv3_rec_infer.onnx"),
          cls_model_dir=os.path.expanduser("~/.paddleocr/onnx/ch_ppocr_mobile_v2.0_cls_infer.onnx"))
```
- 完整报错/Complete Error Message：
```
download https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar to ~/.paddleocr/onnx/ch_PP-OCRv3_det_infer.onnx/ch_PP-OCRv3_det_infer.tar
Process SpawnProcess-5:
Traceback (most recent call last):
  ...
  (some framework file)
  ...
  File "..././main.py", line 32, in <module>
    PaddleOCR(use_onnx=True, det_model_dir=os.path.expanduser("~/.paddleocr/onnx/ch_PP-OCRv3_det_infer.onnx"),
  File "[VENV PATH]/lib/python3.9/site-packages/paddleocr/paddleocr.py", line 457, in __init__
    maybe_download(params.det_model_dir, det_url)
  File "[VENV PATH]/lib/python3.9/site-packages/paddleocr/ppocr/utils/network.py", line 52, in maybe_download
    os.makedirs(model_storage_directory, exist_ok=True)
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '~/.paddleocr/onnx/ch_PP-OCRv3_det_infer.onnx'
```

I've already convert paddleocr model into onnx format, but when I tried to use them in PaddleOCR python class, the maybe_download function still try to download paddle model file. I've created a PR and will submit it soon.


Discussion:

Resolving patch:
diff --git a/paddleocr.py b/paddleocr.py
--- a/paddleocr.py
+++ b/paddleocr.py
@@ -480,10 +480,11 @@ def __init__(self, **kwargs):
             params.rec_image_shape = "3, 48, 320"
         else:
             params.rec_image_shape = "3, 32, 320"
-        # download model
-        maybe_download(params.det_model_dir, det_url)
-        maybe_download(params.rec_model_dir, rec_url)
-        maybe_download(params.cls_model_dir, cls_url)
+        # download model if using paddle infer
+        if not params.use_onnx:
+            maybe_download(params.det_model_dir, det_url)
+            maybe_download(params.rec_model_dir, rec_url)
+            maybe_download(params.cls_model_dir, cls_url)
 
         if params.det_algorithm not in SUPPORT_DET_MODEL:
             logger.error('det_algorithm must in {}'.format(SUPPORT_DET_MODEL))


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
paddleocr中gen_lable.py对icdar2015数据转换有误
![image](https://user-images.githubusercontent.com/119492593/212064964-c7db056f-3209-41f6-a9e0-daa5bc790c61.png)

我用gen_lable.py转换的数据是这样子的，我感觉好像是错误的

不应该是：ch4_training_images/img_1.jpg	[{"transcription": "Genaxis Theatre", "points": [[377, 117], [463, 117], [465, 130], [378, 130]


Discussion:

Resolving patch:
diff --git a/ppocr/utils/gen_label.py b/ppocr/utils/gen_label.py
--- a/ppocr/utils/gen_label.py
+++ b/ppocr/utils/gen_label.py
@@ -29,7 +29,7 @@ def gen_rec_label(input_path, out_label):
 def gen_det_label(root_path, input_dir, out_label):
     with open(out_label, 'w') as out_file:
         for label_file in os.listdir(input_dir):
-            img_path = root_path + label_file[3:-4] + ".jpg"
+            img_path = os.path.join(root_path, label_file[3:-4] + ".jpg")
             label = []
             with open(
                     os.path.join(input_dir, label_file), 'r',
diff --git a/tools/infer/utility.py b/tools/infer/utility.py
--- a/tools/infer/utility.py
+++ b/tools/infer/utility.py
@@ -42,6 +42,7 @@ def init_args():
     parser.add_argument("--min_subgraph_size", type=int, default=15)
     parser.add_argument("--precision", type=str, default="fp32")
     parser.add_argument("--gpu_mem", type=int, default=500)
+    parser.add_argument("--gpu_id", type=int, default=0)
 
     # params for text detector
     parser.add_argument("--image_dir", type=str)
@@ -219,7 +220,7 @@ def create_predictor(args, mode, logger):
                 logger.warning(
                     "GPU is not found in current device by nvidia-smi. Please check your device or ignore it if run on jetson."
                 )
-            config.enable_use_gpu(args.gpu_mem, 0)
+            config.enable_use_gpu(args.gpu_mem, args.gpu_id)
             if args.use_tensorrt:
                 config.enable_tensorrt_engine(
                     workspace_size=1 << 30,


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
paddleocr中gen_lable.py对icdar2015数据转换有误
![image](https://user-images.githubusercontent.com/119492593/212064964-c7db056f-3209-41f6-a9e0-daa5bc790c61.png)

我用gen_lable.py转换的数据是这样子的，我感觉好像是错误的

不应该是：ch4_training_images/img_1.jpg	[{"transcription": "Genaxis Theatre", "points": [[377, 117], [463, 117], [465, 130], [378, 130]


Discussion:

Resolving patch:
diff --git a/ppocr/postprocess/east_postprocess.py b/ppocr/postprocess/east_postprocess.py
--- a/ppocr/postprocess/east_postprocess.py
+++ b/ppocr/postprocess/east_postprocess.py
@@ -81,6 +81,7 @@ def detect(self,
         try:
             check_install('lanms', 'lanms-nova')
             import lanms
+            boxes = lanms.merge_quadrangle_n9(boxes, nms_thresh)
         except:
             print(
                 'You should install lanms by pip3 install lanms-nova to speed up nms_locality'


Test patch:
Repository: PaddlePaddle/PaddleOCR

Issue:
paddleocr中gen_lable.py对icdar2015数据转换有误
![image](https://user-images.githubusercontent.com/119492593/212064964-c7db056f-3209-41f6-a9e0-daa5bc790c61.png)

我用gen_lable.py转换的数据是这样子的，我感觉好像是错误的

不应该是：ch4_training_images/img_1.jpg	[{"transcription": "Genaxis Theatre", "points": [[377, 117], [463, 117], [465, 130], [378, 130]


Discussion:

Resolving patch:
diff --git a/ppocr/modeling/heads/__init__.py b/ppocr/modeling/heads/__init__.py
--- a/ppocr/modeling/heads/__init__.py
+++ b/ppocr/modeling/heads/__init__.py
@@ -17,7 +17,7 @@
 
 def build_head(config):
     # det head
-    from .det_db_head import DBHead, CBNHeadLocal
+    from .det_db_head import DBHead, PFHeadLocal
     from .det_east_head import EASTHead
     from .det_sast_head import SASTHead
     from .det_pse_head import PSEHead
@@ -56,7 +56,7 @@ def build_head(config):
         'TableAttentionHead', 'SARHead', 'AsterHead', 'SDMGRHead', 'PRENHead',
         'MultiHead', 'ABINetHead', 'TableMasterHead', 'SPINAttentionHead',
         'VLHead', 'SLAHead', 'RobustScannerHead', 'CT_Head', 'RFLHead',
-        'DRRGHead', 'CANHead', 'SATRNHead', 'CBNHeadLocal'
+        'DRRGHead', 'CANHead', 'SATRNHead', 'PFHeadLocal'
     ]
 
     if config['name'] == 'DRRGHead':
diff --git a/ppocr/modeling/heads/det_db_head.py b/ppocr/modeling/heads/det_db_head.py
--- a/ppocr/modeling/heads/det_db_head.py
+++ b/ppocr/modeling/heads/det_db_head.py
@@ -129,9 +129,9 @@ def forward(self, x, init_map, distance_map):
         return out
 
 
-class CBNHeadLocal(DBHead):
+class PFHeadLocal(DBHead):
     def __init__(self, in_channels, k=50, mode='small', **kwargs):
-        super(CBNHeadLocal, self).__init__(in_channels, k, **kwargs)
+        super(PFHeadLocal, self).__init__(in_channels, k, **kwargs)
         self.mode = mode
 
         self.up_conv = nn.Upsample(scale_factor=2, mode="nearest", align_mode=1)


Test patch:
Repository: vispy/vispy

Issue:
Pyglet need 1.2 to run
In the Pyglet backend we use `platform_event_loop` which is only available since 1.2 which as alpha status. We cannot use the older `event_loop` since it does not allow processing events without entering the event loop.

My proposal is to check the pyglet version and fail the pyglet backend import with a useful warning.

Having pyglet is useful, because Travis uses it; I was just in a situation where I was unable to reproduce Travis' errors without Pyglet.

BTW: In Travis we install from `http://pyglet.googlecode.com/archive/tip.zip`. 



Discussion:

Resolving patch:
diff --git a/make/make.py b/make/make.py
--- a/make/make.py
+++ b/make/make.py
@@ -168,8 +168,12 @@ def flake(self, arg):
         """ Run flake8 to find style inconsistencies. """
         os.chdir(ROOT_DIR)
         sys.argv[1:] = ['vispy', 'examples', 'make']
-        from flake8.main import main
-        main()
+        try:
+            from flake8.main import main
+        except ImportError:
+            print('Skipping flake8 test, flake8 not installed')
+        else:
+            main()
 
     def images(self, arg):
         """ Create images (screenshots). Subcommands:
diff --git a/vispy/app/backends/__init__.py b/vispy/app/backends/__init__.py
--- a/vispy/app/backends/__init__.py
+++ b/vispy/app/backends/__init__.py
@@ -62,14 +62,13 @@ def has_qt(requires_uic=False, return_which=False):
 
 def has_pyglet(return_which=False):
     try:
-        import pyglet  # noqa
+        from . import _pyglet  # noqa
     except:
         which = None
         has = False
-        pass
     else:
         has = True
-        which = 'pyglet ' + str(pyglet.version)
+        which = 'pyglet ' + str(_pyglet.version)
     if return_which:
         out = (has, which)
     else:
diff --git a/vispy/app/backends/_pyglet.py b/vispy/app/backends/_pyglet.py
--- a/vispy/app/backends/_pyglet.py
+++ b/vispy/app/backends/_pyglet.py
@@ -6,9 +6,16 @@
 vispy backend for pyglet.
 """
 
-# absolute import is important here, since this module is called pyglet :)
 from __future__ import division
 
+from distutils.version import LooseVersion
+import pyglet
+version = pyglet.version
+
+if LooseVersion(version) < LooseVersion('1.2'):
+    raise ImportError('Pyglet version too old (%s), need >= 1.2'
+                      % pyglet.version)
+
 import pyglet.window
 import pyglet.app
 import pyglet.clock


Test patch:
Repository: vispy/vispy

Issue:
The Python process hangs after demos on Windows, Qt backend
If I run any demo, it works, then I close the window, and the process is still running. CTRL+C does not end the process, I have to kill it manually, which is kind of annoying.



Discussion:
Same on Linux.

On Thu, Apr 17, 2014 at 6:32 AM, Cyrille Rossant
notifications@github.comwrote:

> If I run any demo, it works, then I close the window, and the process is
> still running. CTRL+C does not end the process, I have to kill it manually,
> which is kind of annoying.
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/vispy/vispy/issues/228
> .

Same on OSX for some demos (not all).

Seems to have been introduced in 21df29e3629a18

On Thu, Apr 17, 2014 at 7:38 AM, Nicolas P. Rougier <
notifications@github.com> wrote:

> Same on OSX for some demos (not all).
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/vispy/vispy/issues/228#issuecomment-40705195
> .

I wonder why this would make it hang. Any idea @lcampagn?

The window was destroyed before it had a chance to communicate its demise
to the QApplication ?

On Thu, Apr 17, 2014 at 10:34 AM, Eric89GXL notifications@github.comwrote:

> I wonder why this would make it hang. Any idea @lcampagnhttps://github.com/lcampagn
> ?
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/vispy/vispy/issues/228#issuecomment-40720574
> .


Resolving patch:
diff --git a/vispy/app/backends/_qt.py b/vispy/app/backends/_qt.py
--- a/vispy/app/backends/_qt.py
+++ b/vispy/app/backends/_qt.py
@@ -208,9 +208,6 @@ def closeEvent(self, ev):
         if self._vispy_canvas is None:
             return
         self._vispy_canvas.events.close()
-        # Destroy if this is a toplevel widget
-        if self.parent() is None:
-            self.destroy()
 
     def mousePressEvent(self, ev):
         if self._vispy_canvas is None:
@@ -300,6 +297,12 @@ def _modifiers(self, event):
             mod += keys.META,
         return mod
 
+    def __del__(self):
+        # Destroy if this is a toplevel widget
+        if self.parent() is None:
+            self.destroy()
+        QtOpenGL.QGLWidget.__del__(self)
+
 
 # class QtMouseEvent(MouseEvent):
 # special subclass of MouseEvent for propagating acceptance info back to Qt.


Test patch:
Repository: vispy/vispy

Issue:
glsl-sandbox-cube GL_DEPTH issue (Linux Python 2.7.6)
I get the following issue when running glsl-sanbox-cube; setting `GL_DEPTH` doesn't seem to work. 

```
Traceback (most recent call last):
  File "glsl-sandbox-cube.py", line 82, in on_initialize
    gloo.set_state(depth=True)
  File "/usr/local/lib/python2.7/dist-packages/vispy-0.2.1-py2.7.egg/vispy/gloo/wrappers.py", line 531, in set_state
    func(_gl_attr(key))
  File "/usr/local/lib/python2.7/dist-packages/vispy-0.2.1-py2.7.egg/vispy/gloo/wrappers.py", line 43, in _gl_attr
    % (x, y))
ValueError: gl has no attribute corresponding to name depth (GL_DEPTH)
```

However when I check `PyOpenGL`:

```
import OpenGL.GL as gl
print gl.GL_DEPTH
>> GL_DEPTH (6145)
```



Discussion:

Resolving patch:
diff --git a/examples/glsl-sandbox-cube.py b/examples/glsl-sandbox-cube.py
--- a/examples/glsl-sandbox-cube.py
+++ b/examples/glsl-sandbox-cube.py
@@ -79,7 +79,7 @@ def __init__(self, **kwargs):
 
     def on_initialize(self, event):
         gloo.set_clear_color((1, 1, 1, 1))
-        gloo.set_state(depth=True)
+        gloo.set_state(depth_test=True)
 
     def on_resize(self, event):
         width, height = event.size


Test patch:
Repository: vispy/vispy

Issue:
Possible bug with multiple programs?
I got a weird behavior that looks like a bug, unless I'm doing something wrong when painting two programs.

The following example should, in principle, display two squares: one blue on the bottom left, one red on the top right. Only the last draw call seems to be taken into account. Tested on Windows 8.1 Python 2.7 64-bit with AMD graphics card.

``` python
from vispy import gloo
from vispy import app
import numpy as np

position1 = np.zeros((1, 2)).astype(np.float32)-.5
position2 = np.zeros((1, 2)).astype(np.float32)+.5

VERT_SHADER = """
attribute vec2 a_position;
void main() {
    gl_Position = vec4(a_position, 0.0, 1.0);
    gl_PointSize = 30.0;
}
"""

FRAG_SHADER1 = """
void main() {
    gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
"""

FRAG_SHADER2 = """
void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
"""

class Canvas(app.Canvas):
    def __init__(self):
        app.Canvas.__init__(self, close_keys='escape')

        self.program1 = gloo.Program(VERT_SHADER, FRAG_SHADER1)  # blue on the left
        self.program1['a_position'] = position1

        self.program2 = gloo.Program(VERT_SHADER, FRAG_SHADER2)  # red on the right
        self.program2['a_position'] = position2

    def on_resize(self, event):
        width, height = event.size
        gloo.set_viewport(0, 0, width, height)

    def on_paint(self, event):
        gloo.clear(color=(0.0, 0.0, 0.0, 1.0))
        self.program1.draw('points')
        self.program2.draw('points')

c = Canvas()
c.show()
app.run()
```



Discussion:
Confirmed -- I also only get the second (red) square. If I comment out the second draw, the first (blue) square shows up. @almarklein @rougier any idea?

Try:

```
    def _activate(self):
        if isinstance(self.data, VertexBuffer):
            self.data.activate()
            size, gtype, dtype = gl_typeinfo[self._gtype]
            stride = self.data.stride
            gl.glEnableVertexAttribArray(self.handle)
            gl.glVertexAttribPointer(self.handle, size, gtype, gl.GL_FALSE,
                                     stride, ctypes.c_void_p(0)
```

in vispy/gloo/variable.py in Attribute._activate()


Resolving patch:
diff --git a/vispy/gloo/variable.py b/vispy/gloo/variable.py
--- a/vispy/gloo/variable.py
+++ b/vispy/gloo/variable.py
@@ -324,6 +324,11 @@ def set_data(self, data):
     def _activate(self):
         if isinstance(self.data, VertexBuffer):
             self.data.activate()
+            size, gtype, dtype = gl_typeinfo[self._gtype]
+            stride = self.data.stride
+            gl.glEnableVertexAttribArray(self.handle)
+            gl.glVertexAttribPointer(self.handle, size, gtype, gl.GL_FALSE,
+                                     stride, self.data.offset)
     
     def _deactivate(self):
         if isinstance(self.data, VertexBuffer):


Test patch: