Why NSAttributedString import html must be on main thread?
The HTML importer should not be called from a background thread (that is, the options dictionary includesNSDocumentTypeDocumentAttribute with a value of NSHTMLTextDocumentType). It will try to synchronize with the main thread, fail, and time out. Calling it from the main thread works (but can still time out if the HTML contains references to external resources, which should be avoided at all costs). The HTML import mechanism is meant for implementing something like markdown (that is, text styles, colors, and so on), not for general HTML import.
Multicore considerations:
Since OS X v10.4, NSAttributedString has used WebKit for all import (but not for export) of HTML documents. Because WebKit document loading is not thread safe, this has not been safe to use on background threads. For applications linked on OS X v10.5 and later, if NSAttributedString imports HTML documents on any but the main thread, the use of WebKit is transferred to the main thread via performSelectorOnMainThread:withObject:waitUntilDone:. This makes the operation thread safe, but it requires that the main thread be executing the run loop in one of the common modes. This behavior can be overridden by setting the value of the standard user default NSRunWebKitOnAppKitThread to either YES(to obtain the new behavior regardless of linkage) or NO (to obtain the old behavior regardless of linkage).
在主线程中加载的网页如果很大,就会很慢 ,唉,在做时尚周刊时,那里面加载了html页面,不知道core text怎么样,没试过。
Why NSAttributedString import html must be on main thread?的更多相关文章
- main thread starting…
例的结果,下面的: main thread starting- Thrad 2 staring- Thrad 2 end- Thrad 4 staring- Thrad 4 end- Thrad 1 ...
- tensorflow_目标识别object_detection_api,RuntimeError: main thread is not in main loop,fig = plt.figure(frameon=False)_tkinter.TclError: no display name and no $DISPLAY environment variable
最近在使用目标识别api,但是报错了: File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_o ...
- Sub Thread to update main Thread (UI) 2
Sub Thread to update main Thread (UI) 2 Handler.post(somethread); Handler.sendMessage("Msg&quo ...
- Sub Thread to update main Thread (UI)
Sub Thread to update main Thread (UI) main Thread : A has Hander.HandleMessage() to process the & ...
- celery 错误相关:Monkey-patching not on the main thread; threading.main_thread().join() will hang from a greenlet
/Users/wangpingyang/.pyenv/versions/3.7.2/lib/python3.7/site-packages/httprunner/__init__.py:5: Monk ...
- 13、主线程任务太多导致异常退出(The application may be doing too much work on its main thread)
今天花费了一天的时间来解决这个bug. 这种在程序运行期间出现的问题比较棘手,如果再没有规律的话就更难解决. 还好这个bug是由规律的,也就是说在程序执行半个小时左右后就会因为此异常而导致程序退出:那 ...
- reloadData should be in main thread
reloadData should be called in main thread, so if you call it in work thread, you should call it as ...
- APP崩溃提示:This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
崩溃输出日志 2017-08-29 14:53:47.332368+0800 HuiDaiKe[2373:1135604] This application is modifying the auto ...
- Ajax.html:35 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org
AJAX的容易错误的地方 Ajax.html:35 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated ...
随机推荐
- minicom 使用教程
因为现在电脑基本不配备串行接口,所以,usb转串口成为硬件调试时的必然选择.目前知道的,PL2303的驱动是有的,在dev下的名称是ttyUSB#. minicom,tkterm都是linux下应用比 ...
- Python多进程编程
转自:Python多进程编程 阅读目录 1. Process 2. Lock 3. Semaphore 4. Event 5. Queue 6. Pipe 7. Pool 序. multiproces ...
- HashMap代码示例
package com.shushine.framework.第七章Java标准类库;import java.util.HashMap;import java.util.Iterator;import ...
- CentOS6.5 mysql 5.5安装
CentOS 6 mysql5.5安装配置 1 安装所需软件 2 安装cmake 3 tar.gz形式安装mysql 4 配置与启动 MySQL自5.5版本以后,就开始使用cmake编译工具了.tar ...
- 《BI项目笔记》创建标准维度、维度自定义层次结构
- 关于JS的数据类型的一些见解
关于js里的数据类型这块,说下个人对它的一些见地 js中的数据类型可以归类两类, 简单数据类型:string,number,boolean,null,undefined 复杂数据类型:object 其 ...
- LTE Module User Documentation(翻译8)——核心网(EPC)
LTE用户文档 (如有不当的地方,欢迎指正!) 14 Evolved Packet Core (EPC) 我们现在讲解如何编写一个仿真程序——除了 LTE 无线接入网外,还允许仿真 EPC. EP ...
- [Prodinner项目]学习分享_第二部分_Entity到DB表的映射
1.单纯映射 基本语法为 modelBuilder.Entity<InsType>().ToTable("TB_InsType"); 2.一对多映射(表关系) 实体类B ...
- Pycharm使用问题# 行号设置
设置行号就很简单了,在Settings中找到Editor-Appearance,选中Show line numbers即可.
- Error: Cannot find a valid baseurl for repo: base
解决方法如下(修改dns配置) vi /etc/resolv.conf 在此文件最后加入:nameserver 8.8.8.8 如果没有vi编辑器可用: echo "nameserver 8 ...