阅读更多 Android: Your JS Engine is not always V8 | January 14th, 2011 Joe Bowser’s Blog


Recently, I watched some Mobile Web training, and I noticed that people overlook many things about Android. Namely these facts:

WebKit is different on every phone
The Browser and the WebKit engine are different things.
WebKit can have a different engine
So, as usual I will talk about how the source to Android is OPEN, and how with the source code, I can look at the build scripts and find out what Android ACTUALLY supports instead of doing feature detection or the other things people in turtlenecks use to decide what Android can and can’t do very well. Below is the applicable Makefile for WebKit:


# To enable JIT in Android's JSC, please set ENABLE_JSC_JIT environment
# variable to true.

# Read JS_ENGINE environment variable
JAVASCRIPT_ENGINE = $(JS_ENGINE)

# The default / alternative engine depends on the device class.
# On devices with a lot of memory (e.g. Passion/Sholes), the
# default is V8. On everything else, the only choice is JSC.
# TODO: use ARCH_ARM_HAVE_ARMV7 once that variable is added to
# the build system.
ifeq ($(ARCH_ARM_HAVE_VFP),true)
DEFAULT_ENGINE = v8
ALT_ENGINE = jsc
else
DEFAULT_ENGINE = jsc
ALT_ENGINE = jsc
endif

ifneq ($(JAVASCRIPT_ENGINE),jsc)
ifneq ($(JAVASCRIPT_ENGINE),v8)
# No JS engine is specified, pickup the one we want as default.
ifeq ($(USE_ALT_JS_ENGINE),true)
JAVASCRIPT_ENGINE = $(ALT_ENGINE)
else
JAVASCRIPT_ENGINE = $(DEFAULT_ENGINE)
endif
endif
endif

# Two ways to control which JS engine is used:
# 1. use JS_ENGINE environment variable, value can be either 'jsc' or 'v8'
# This is the preferred way.
# 2. if JS_ENGINE is not set, or is not 'jsc' or 'v8', this makefile picks
# up a default engine to build.
# To help setup buildbot, a new environment variable, USE_ALT_JS_ENGINE,
# can be set to true, so that two builds can be different but without
# specifying which JS engine to use.

# To enable JIT in Android's JSC, please set ENABLE_JSC_JIT environment
# variable to true.

# Read JS_ENGINE environment variable
JAVASCRIPT_ENGINE = $(JS_ENGINE)

# The default / alternative engine depends on the device class.
# On devices with a lot of memory (e.g. Passion/Sholes), the
# default is V8. On everything else, the only choice is JSC.
# TODO: use ARCH_ARM_HAVE_ARMV7 once that variable is added to
# the build system.
ifeq ($(ARCH_ARM_HAVE_VFP),true)
DEFAULT_ENGINE = v8
ALT_ENGINE = jsc
else
DEFAULT_ENGINE = jsc
ALT_ENGINE = jsc
endif

ifneq ($(JAVASCRIPT_ENGINE),jsc)
ifneq ($(JAVASCRIPT_ENGINE),v8)
# No JS engine is specified, pickup the one we want as default.
ifeq ($(USE_ALT_JS_ENGINE),true)
JAVASCRIPT_ENGINE = $(ALT_ENGINE)
else
JAVASCRIPT_ENGINE = $(DEFAULT_ENGINE)
endif
endif
endif



So, if you’re running a low-end Android device, like a Motorola Quench, your Javascript Engine will be different from the Nexus S, HTC EVO with CM7, the Motorola Droid, the Nexus One, etc. Since nobody has seen the official Android 2.3 on anything other than the Nexus S, I can only really do experiments with Cyanogen on an HTC Dream, which isn’t really accurate.

Recently, there was an issue with the emulator image on Android 2.3 that directly affected PhoneGap. Because I have no idea what Javascript Engine is on the emulators, I suspect that this image may creep up again on low-end phones and cause even more fragmentation than before. This is a REALLY bad thing, since it makes web development on Android even more frustrating, and will chase developers away from that platform. Like everything else in Android, things are always changing, so if any phone manufacturers are reading this and can test PhoneGap on their low-end line and get back to me, that would be greatly appreciated.

更多相关文章

  1. Android recyclerview实现查看更多/收起功能
  2. Android ListView列表 刷新和加载更多
  3. Jquery点击加载更多
  4. 《锋利的jQuery》读书笔记 第5章 jQuery对表单、表格的操作及更
  5. 关于jQuery Themeroller主题,我在哪里可以找到更多?
  6. DataTables警告:table id = DataTables_Table_0 - Ajax错误。有
  7. 总结一些更多的针对webkit的HTML, CSS和Javascript方面的特性.
  8. Joomla 3.x“错误检出失败,出现以下错误:”没有更多信息
  9. 如何使用jQuery将输入值插入更多填充的字段?

随机推荐

  1. Chrome for Android 也将具备 Opera Mobi
  2. android骚年的年终总结和规划
  3. 全面的Android文件目录解析和获取方法(包
  4. Android官方文档——管理activity的生命
  5. Android assets 目录作用
  6. 在32位的Ubuntu 11.04中为Android NDK r6
  7. Android 预编译模块
  8. android handler和thread的使用
  9. android各版本特性
  10. 什么是Android上的USB调试模式以及如何启