NativeScript / NativeScript/android

Running some native code for the first time results in application lag

未关闭
#1,330 6 条评论 2 个 reaction 已指派 1 人 在 GitHub 查看

@triniwiz 已经在做这个了。

开始于 2021年9月8日。

主要语言
C++
星标
563
派生
144
平均合并
10 小时 46 分钟
30 天内合并 PR
14

描述

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.3.0
  • Cross-platform modules: 5.3.1
  • Android Runtime: 5.2.x and 5.3.0 tested

Describe the bug
When using trying to use some android variables or instantiate some instances, the first call will have a heavy delay (500-600ms on a Galaxy S8).

Using the playground, reading android.R.integer.config_shortAnimTime, android.R.attr.state_pressed and android.R.attr.state_enabled all caused a delay, which froze the UI.

Downloading the project and using NS 5.3, calling nativeView.getContext().getResources().getInteger also called a delay and freeze. Edit: Running with --bundle shortens this delay for some reason (takes something like 30-40ms)

This freeze happens only on the first time the code is run, after that it takes less than 10ms.

To Reproduce
Measure how long it takes to call:

const t = android.R.integer.config_shortAnimTime; // should take long on first time
nativeView.getContext().getResources().getInteger(t); // should take long on first time in 5.3

Expected behavior
These calls should behave on the first time as they do on the second and onward.

Sample project
https://play.nativescript.org/?template=play-ng&id=28zxPb&v=6

Additional context
We discovered it by https://github.com/JoshDSommer/nativescript-ngx-shadow/issues/16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。