dll冻结浏览器的js-ctypes [英] js-ctypes with dll freezing browser

查看:101
本文介绍了dll冻结浏览器的js-ctypes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用带有自己开发的dll的js-ctypes从html页面中的图像设备获取图片. (计时器->从设备获取图片-> bmp 300kb base64-> html) 每0.2秒Addon调用映像设备一次,并且每次Addon正常工作的浏览器在0.5秒后冻结. (英特尔i5、16GB DDR)

We use js-ctypes with own developed dll to get picture from image device in html page. (timer-> get picture from device -> bmp 300kb base64 -> html ) Every 0.2 sec Addon calling image device and every time addon working browser freezing at 0.5 sec. (intel i5, 16gb ddr)

我不知道如何在不冻结浏览器的情况下使用js-ctypes. 做出异步响应,我认为使用js-ctypes并不酷. 也许需要使用端口,而无需等待图像设备的响应?

I don't know how to use js-ctypes without freezing browser. Make async response i think not cool with js-ctypes. Maybe need using ports without waiting response from image device?

推荐答案

异步使用js-ctypes的最简单方法是 ChromeWorker .您在其中拥有全局ctypes对象以使用js-ctypes-并且执行在单独的线程上运行,因此您不必担心会阻塞浏览器.如果以后需要在主线程中使用数据,则可以发送消息就像在通常的网络工作者中一样.

The simplest way to use js-ctypes asynchronously is ChromeWorker. You have the global ctypes object there to use js-ctypes - and the execution runs on a separate thread so you don't have to worry about blocking the browser. If you need the data in the main thread later, you can send a message like in a usual web worker.

注意:如果您使用的是附加SDK,那么您会发现ChromeWorker没有公开在您的模块中.有一个简单的解决方法.

Note: If you are using the Add-on SDK then you will notice that ChromeWorker isn't exposed in your modules. There is an easy work-around for that.

这篇关于dll冻结浏览器的js-ctypes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆