NativeScript / NativeScript/android

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

Aperta
#1,330 6 commenti 2 reazioni 1 assegnatario Vedi su GitHub

@triniwiz ci sta già lavorando.

Dal 8/9/2021.

Lingua principale
C++
Stelle
563
Fork
144
Merge medio
10h 46m
PR unite (30g)
14

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.