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?的更多相关文章

  1. main thread starting…

    例的结果,下面的: main thread starting- Thrad 2 staring- Thrad 2 end- Thrad 4 staring- Thrad 4 end- Thrad 1 ...

  2. 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 ...

  3. Sub Thread to update main Thread (UI) 2

    Sub Thread to update main Thread (UI)  2 Handler.post(somethread); Handler.sendMessage("Msg&quo ...

  4. Sub Thread to update main Thread (UI)

    Sub Thread to update main Thread (UI) main Thread :   A  has Hander.HandleMessage() to process the & ...

  5. 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 ...

  6. 13、主线程任务太多导致异常退出(The application may be doing too much work on its main thread)

    今天花费了一天的时间来解决这个bug. 这种在程序运行期间出现的问题比较棘手,如果再没有规律的话就更难解决. 还好这个bug是由规律的,也就是说在程序执行半个小时左右后就会因为此异常而导致程序退出:那 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 编写windows7 bat运行脚本

    每天上班,打开电脑后,我总是会固定的打开几个软件.这是重复的工作,我要写脚本startup.bat,直接点击它,就可以启动这些软件了. 本文主要参考这里,只用到了start 和 @Rem 两个命令语句 ...

  2. hadoop运维经验

    0.优化:http://dongxicheng.org/mapreduce/hadoop-optimization-0/ http://dongxicheng.org/mapreduce/hadoop ...

  3. iptables命令详解和举例

    网上看到这个配置讲解得还比较易懂,就转过来了,大家一起看下,希望对您工作能有所帮助.网管员的安全意识要比空喊Linux安全重要得多. iptables -Fiptables -Xiptables -F ...

  4. Hadoop集群环境搭建

    ----------------------------------------------------------- 自学记录,交流学习请发送邮件至gxz1984@gmail.com ------- ...

  5. Linux -- 文件统计常用命令

    标签(空格分隔): Linux sort -- 文件内排序命令 sort将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,依次比较其ASCII码. 按每行升序排序: sort seq.tx ...

  6. REST 架构风格

    目前基于网络应用的架构风格主要有三种: RPC架构风格   将服务器看作是由一些过程组成,客户端调用这些过程来执行特定的任务.SOAP就是RPC风格的一种架构.过程是动词性的(做某件事),因此RPC建 ...

  7. mac pycharm配置 python

    一.首先查看自己安装的python的路径 在terminal运行 which python(which命令只是根据PATH环境变量找) 例如:/usr/bin/python 二.设置python版本 ...

  8. Delphi名站以及高手Blog

    以前知道的: http://cnblogs.com/del (万一兄的,这个不用解释了) http://www.cnblogs.com/del/archive/2010/04/25/1720750.h ...

  9. Eclipse+Tomcat+MAVEN+SVN项目完整环境搭建

    1.JDK的安装 首先下载JDK,这个从sun公司官网可以下载,根据自己的系统选择64位还是32位,安装过程就是next一路到底.安装完成之后当然要配置环境变量了. ————————————————— ...

  10. php 对多维数组排序array_multisort

    php 对多维数组排序array_multisort 排序顺序标志: SORT_ASC - 按照上升顺序排序 SORT_DESC - 按照下降顺序排序 排序类型标志: SORT_REGULAR - 将 ...