-2

I am an Android beginner and write a simple app to test grid view. I execute the app on simulator and display running message in the run window. whenever I click the button, it shows

“….Skipped 70 frames! The application may be doing too much work on its main thread.”

running message. My question is why the run window shows the message. Is it normal or abnormal?

My source code as below:

enter code here`package com.example.lulala.exgridview01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity {
    private GridView gridView;
    private int[] image = {
      R.drawable.plant1, R.drawable.plant2, R.drawable.plant3,
      R.drawable.plant4, R.drawable.plant5, R.drawable.plant6,
      R.drawable.plant7, R.drawable.plant8, R.drawable.plant9,
      R.drawable.plant10, R.drawable.plant11, R.drawable.plant12,
};
    private String[] imgText = {
           "plant1","plant2","plant3","plant4","plant5","plant6",
           "plant7","plant8","plant9","plant10","plant11","plant12"
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        List<Map<String,Object>> items = new ArrayList<>();
        for (int i = 0; i < image.length; i++){
            Map<String,Object> item = new HashMap<>();
            item.put("image",image[i]);
            item.put("text",imgText[i]);
            items.add(item);
        }
        SimpleAdapter adapter = new SimpleAdapter(this,items,R.layout.grid_item,   
               new String[]{"image","text"},new int[]{R.id.image,R.id.text});
        gridView = findViewById(R.id.main_gridview);
        gridView.setNumColumns(3);
        gridView.setAdapter(adapter);

        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int   
                      position, long id) {
                    Toast.makeText(MainActivity.this, " Choice: 
                       "+imgText[position],Toast.LENGTH_LONG).show();
                    }
          });
    }
}

The running window shows as below:

08/12 13:46:50: Launching app
$ adb install-multiple -r -t /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/resources/instant-run/debug/resources-debug.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_0.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_5.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_1.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/dep/dependencies.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_8.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_3.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_2.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_4.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_9.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_6.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/split-apk/debug/slices/slice_7.apk /Users/lulala/AndroidStudioProjects/ExGridView01/app/build/intermediates/instant-run-apk/debug/app-debug.apk 
Split APKs installed
$ adb shell am start -n "com.example.lulala.exgridview01/com.example.lulala.exgridview01.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Waiting for process to come online
Connected to process 2914 on device Nexus_6_API_28 [emulator-5554]
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/la.exgridview0: Not late-enabling -Xcheck:jni (already on)
W/la.exgridview0: Unexpected CPU variant for X86 using defaults: x86
W/la.exgridview0: JIT profile information will not be recorded: profile file does not exits.
I/chatty: uid=10068(com.example.lulala.exgridview01) identical 10 lines
W/la.exgridview0: JIT profile information will not be recorded: profile file does not exits.
I/InstantRun: starting instant run server: is main process
W/la.exgridview0: Verification of void com.android.tools.ir.server.Server.<init>(java.lang.String, android.content.Context) took 132.849ms
W/la.exgridview0: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/la.exgridview0: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
W/la.exgridview0: JNI critical lock held for 53.436ms on Thread[1,tid=2914,Runnable,Thread*=0xeb974000,peer=0x73a22760,"main"]
D/OpenGLRenderer: Skia GL Pipeline
D/: HostConnection::get() New Host Connection established 0xe79cd640, tid 2960
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
               android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
D/EGL_emulation: eglCreateContext: 0xe5985180: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xe5985180: ver 3 0 (tinfo 0xe59836e0)
I/Choreographer: Skipped 158 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xe5985180: ver 3 0 (tinfo 0xe59836e0)
I/OpenGLRenderer: Davey! duration=14060ms; Flags=0, IntendedVsync=143256734995, Vsync=145890068223, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=145900479118, AnimationStart=145900638744, PerformTraversalsStart=145900717608, DrawStart=145917488092, SyncQueued=145982042449, SyncStart=145984617369, IssueDrawCommandsStart=145984761951, SwapBuffers=153712375702, FrameCompleted=157319988695, DequeueBufferDuration=80000, QueueBufferDuration=5482000, 
I/OpenGLRenderer: Davey! duration=1051ms; Flags=0, IntendedVsync=158063467774, Vsync=158063467774, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=158068354187, AnimationStart=158068530330, PerformTraversalsStart=158068548390, DrawStart=158083973844, SyncQueued=158231144838, SyncStart=158243179453, IssueDrawCommandsStart=158244003412, SwapBuffers=158317220295, FrameCompleted=159126723311, DequeueBufferDuration=93000, QueueBufferDuration=468000, 
I/Choreographer: Skipped 57 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=1587ms; Flags=0, IntendedVsync=158230110721, Vsync=159180110683, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=159182195370, AnimationStart=159182263238, PerformTraversalsStart=159182268410, DrawStart=159182688099, SyncQueued=159186028517, SyncStart=159186064225, IssueDrawCommandsStart=159186187430, SwapBuffers=159188081253, FrameCompleted=159817779420, DequeueBufferDuration=269356000, QueueBufferDuration=2136000, 
I/Choreographer: Skipped 56 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=3354ms; Flags=0, IntendedVsync=165328242627, Vsync=166261575923, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=166272352984, AnimationStart=166272383637, PerformTraversalsStart=166273013513, DrawStart=166274315053, SyncQueued=166276475096, SyncStart=166277534365, IssueDrawCommandsStart=166277761222, SwapBuffers=166662844892, FrameCompleted=168683978150, DequeueBufferDuration=108000, QueueBufferDuration=20807000, 
I/Choreographer: Skipped 170 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=3934ms; Flags=1, IntendedVsync=166275904019, Vsync=169109237239, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=169119053142, AnimationStart=169119110686, PerformTraversalsStart=169272676122, DrawStart=169978922653, SyncQueued=169980961358, SyncStart=169983340048, IssueDrawCommandsStart=169983483331, SwapBuffers=169984275898, FrameCompleted=170212782068, DequeueBufferDuration=29462000, QueueBufferDuration=40703000, 
I/Choreographer: Skipped 66 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xe5985180: ver 3 0 (tinfo 0xe59836e0)
I/OpenGLRenderer: Davey! duration=1297ms; Flags=0, IntendedVsync=169121988469, Vsync=170221988425, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=170234924519, AnimationStart=170234987750, PerformTraversalsStart=170238398545, DrawStart=170254693108, SyncQueued=170256053997, SyncStart=170315148618, IssueDrawCommandsStart=170315275215, SwapBuffers=170316341432, FrameCompleted=170478422121, DequeueBufferDuration=91000, QueueBufferDuration=6982000, 
D/EGL_emulation: eglMakeCurrent: 0xe5985180: ver 3 0 (tinfo 0xe59836e0)
I/OpenGLRenderer: Davey! duration=1506ms; Flags=0, IntendedVsync=169121988469, Vsync=170221988425, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=170234924519, AnimationStart=170234987750, PerformTraversalsStart=170238398545, DrawStart=170481419790, SyncQueued=170487377732, SyncStart=170620834016, IssueDrawCommandsStart=170621281280, SwapBuffers=170622257415, FrameCompleted=170761842062, DequeueBufferDuration=2244000, QueueBufferDuration=20196000, 
I/Choreographer: Skipped 39 frames!  The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=1650ms; Flags=1, IntendedVsync=171390729511, Vsync=171690729499, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=171692184776, AnimationStart=171706315802, PerformTraversalsStart=171706981970, DrawStart=172732183409, SyncQueued=172795785610, SyncStart=172795826236, IssueDrawCommandsStart=172795917974, SwapBuffers=172813553731, FrameCompleted=173041471134, DequeueBufferDuration=707000, QueueBufferDuration=10743000, 
I/Choreographer: Skipped 82 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xe5985180: ver 3 0 (tinfo 0xe59836e0)
prashant17
  • 1,520
  • 3
  • 14
  • 23
mml
  • 1
  • 1
  • 3
  • Do not post screenshots of code or logcats. It is a pain for everyone to read and deal with, and is not accessible to those who use screen readers, for example for reasons of disability, *especially* when you fail to provide useful alt-tags as you are directed to do by "enter image description here". Use code formatting and post an MCVE in text format. – nanofarad Aug 12 '18 at 05:31
  • What is the task after tap the button? Do not do I/o, network task, complex task in ui thread, use asynctask or threads. – Neo Shen Aug 12 '18 at 06:06
  • I think it is not a proper sample code to test grid view and after my research "Do not do I/o, network task, the complex task in ui thread, use asynctask or threads." is the best answer. Thanks for everyone to reply to my question. – mml Aug 12 '18 at 22:40

2 Answers2

0

For me the reason was "vmSafeMode" set to "true" in debug AndroidManifest, i guess it is somehow optimizing for emulators but slows down on real devices

KubenQPL
  • 113
  • 2
  • 11
-2

Most probably your drawables must be of large size that must be causing heavy processing and rendering.Try to lower the size of drawables that are included in private int[] image

Anubhav Gupta
  • 2,492
  • 14
  • 27