致命错误信号16(SIGSTKFLT)已意外发生

致命错误信号16(SIGSTKFLT)已意外发生,第1张

概述今天,我面临一个奇怪的问题.我在三个设备上安装了我的应用程序>华硕TransformerPadInfinityTF700T>三星I9082GalaxyGrandDuos>LGOptimusL7IIDualp715首先,我使用所有这些设备在Debug模式下从Eclipse运行了我的应用程序.没关系然后,我以通常的方式(在设备上)运行我

今天,我面临一个奇怪的问题.
我在三个设备上安装了我的应用程序

>华硕transformer Pad Infinity TF700T
>三星I9082 galaxy Grand Duos
> LG Optimus L7 II Dual p715

首先,我使用所有这些设备在DeBUG模式下从Eclipse运行了我的应用程序.没关系

然后,我以通常的方式(在设备上)运行我的应用程序.这样,我所有的坏事就开始了.对于1和2台设备都可以.但是3台设备无法正常工作. LogCat向我显示了以下致命错误

01-14 01:36:47.529: E/dalvikvm(11294): threadID=1: stuck on
threadID=14, giving up 01-14 01:36:47.529: A/libc(11294): Fatal signal
16 (SIGSTKFLT) at 0x00002c1e (code=-6), thread 11315 (AsyncTask #4)

我真的不明白,这是怎么回事,为什么1和2的设备都能正常工作,而第三个设备却不能.

谁能解释我,这个错误是什么意思,如何纠正?

UPD1我不使用NDK调用和任何第三方库.

UPD2导致错误的大代码段是(我在这里包括所有事件都将调用绘制过程并将其停止):

//I included all imports for sure that I don't use nothing instead of standard thingsimport java.io.file;import java.io.fileFilter;import java.io.IOException;import java.io.inputStream;import java.util.ArrayList;import java.util.List;import androID.content.broadcastReceiver;import androID.content.Context;import androID.content.Intent;import androID.content.IntentFilter;import androID.content.SharedPreferences;import androID.content.SharedPreferences.OnSharedPreferencechangelistener;import androID.content.res.Configuration;import androID.content.res.Resources;import androID.graphics.Bitmap;import androID.graphics.Bitmap.Config;import androID.graphics.Canvas;import androID.graphics.color;import androID.graphics.Matrix;import androID.graphics.Paint;import androID.graphics.Path;import androID.graphics.Region;import androID.graphics.drawable.Drawable;import androID.os.AsyncTask;import androID.os.Build;import androID.os.Handler;import androID.service.wallpaper.WallpaperService;import androID.util.displayMetrics;import androID.util.Log;import androID.vIEw.display;import androID.vIEw.GestureDetector;import androID.vIEw.GestureDetector.SimpleOnGestureListener;import androID.vIEw.MotionEvent;import androID.vIEw.SurfaceHolder;import androID.vIEw.WindowManager;public class MyliveWallpaper extends WallpaperService {    public static final String CONfigS = "configs";    private WallpaperEngine we;    @OverrIDe    public voID onCreate() {            super.onCreate();    }    @OverrIDe    public voID onDestroy() {            super.onDestroy();            if(we.myDrawTask!=null){                    we.myDrawTask.cancel(false);            }    }    @OverrIDe    public Engine onCreateEngine() {            we = new WallpaperEngine();            return we;    }    //DeviceScreenSize is some class where I just incapsulate screen wIDth, height and depth obtained in getScreenSize() method    DeviceScreenSize dss = new DeviceScreenSize(0, 0, 0);    class WallpaperEngine extends Engine implements                    OnSharedPreferencechangelistener {            //Some deFinitions below            ............................            public DrawTask myDrawTask = null;            ............................            //Some deFinitions above            WallpaperEngine() {                    ..............                    doubleTapDetector = new GestureDetector(HDliveWallpaper.this,                                    new SimpleOnGestureListener() {                            @OverrIDe                            public boolean onDoubleTap(MotionEvent e) {                                    if (mtouchEvents) {                                            mLastDrawTime = 0;                                            if(myDrawTask!=null){                                                    myDrawTask.stopAnimationFlag = true;                                            }                                            else{                                                    myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                                                    myDrawTask.execute();                                            }                                            return true;                                    }                                    return false;                            }                    });            }            @OverrIDe            public voID onCreate(SurfaceHolder surfaceHolder) {                    super.onCreate(surfaceHolder);                    // Register receiver for media events                    IntentFilter filter = new IntentFilter();                    filter.addAction(Intent.ACTION_MEDIA_BAD_REMoval);                    filter.addAction(Intent.ACTION_MEDIA_CHECKING);                    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);                    filter.addAction(Intent.ACTION_MEDIA_EJECT);                    filter.addAction(Intent.ACTION_MEDIA_NOFS);                    filter.addAction(Intent.ACTION_MEDIA_REMOVED);                    filter.addAction(Intent.ACTION_MEDIA_SHARED);                    filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);                    filter.addDataScheme("file");                    mReceiver = new broadcastReceiver() {                            @OverrIDe                            public voID onReceive(Context context, Intent intent) {                                    String action = intent.getAction();                                    if (action.equals(Intent.ACTION_MEDIA_MOUNTED) || action.equals(Intent.ACTION_MEDIA_CHECKING)) {                                            mStorageReady = true;                                            settouchEventsEnabled(true);                                            if(myDrawTask!=null){                                                    myDrawTask.cancel(false);                                            }                                            myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                                            myDrawTask.execute();                                    } else {                                            mStorageReady = false;                                            settouchEventsEnabled(false);                                            if(myDrawTask!=null) myDrawTask.cancel(false);                                    }                            }                    };                    registerReceiver(mReceiver, filter);                    // Register receiver for screen on events                    mScreenOnRecIEver = new broadcastReceiver() {                            @OverrIDe                            public voID onReceive(Context context, Intent intent) {                                    System.out.println(Intent.ACTION_SCREEN_ON);                                    if (mScreenWake) {                                            mLastDrawTime = 0;                                    }                                    if(myDrawTask!=null){                                            myDrawTask.cancel(false);                                    }                                    myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                                    myDrawTask.execute();                            }                    };                     registerReceiver(mScreenOnRecIEver, new IntentFilter(Intent.ACTION_SCREEN_ON));                    mScreenOffRecIEver = new broadcastReceiver() {                            @OverrIDe                            public voID onReceive(Context context, Intent intent) {                                    System.out.println(Intent.ACTION_SCREEN_OFF);                                    if (mScreenWake) {                                            mLastDrawTime = 0;                                    }                                    if(myDrawTask!=null){                                            myDrawTask.cancel(false);                                    }                            }                    };                     registerReceiver(mScreenOffRecIEver, new IntentFilter(Intent.ACTION_SCREEN_OFF));                    settouchEventsEnabled(mStorageReady);            }            @OverrIDe            public voID onDestroy() {                    super.onDestroy();                    mPrefs.unregisterOnSharedPreferencechangelistener(this);                    unregisterReceiver(mReceiver);                    unregisterReceiver(mScreenOnRecIEver);                    unregisterReceiver(mScreenOffRecIEver);                    if(myDrawTask!=null){                            myDrawTask.cancel(false);                    }            }            @OverrIDe            public voID onVisibilityChanged(boolean visible) {                    mVisible = visible;                    if (visible) {                            if(myDrawTask!=null){                                    myDrawTask.cancel(false);                            }                            myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                            myDrawTask.execute();                            mLastDrawTime = 0;                    } else {                            if(myDrawTask!=null){                                    myDrawTask.cancel(false);                            }                    }            }            @OverrIDe            public voID onSurfaceChanged(SurfaceHolder holder, int format,            int wIDth, int height) {                    super.onSurfaceChanged(holder, format, wIDth, height);                    .....................                    if (mBitmap != null) {                            mBitmap.recycle();                    }                    if(myDrawTask!=null){                            myDrawTask.cancel(false);                    }                    myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                    myDrawTask.execute();            }            @OverrIDe            public voID onSurfaceCreated(SurfaceHolder holder) {                    super.onSurfaceCreated(holder);                    if(myDrawTask!=null){                            myDrawTask.cancel(false);                    }                    myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                    myDrawTask.execute();                    mLastDrawTime = 0;            }            @OverrIDe            public voID onSurfaceDestroyed(SurfaceHolder holder) {                    super.onSurfaceDestroyed(holder);                    mVisible = false;                    if(myDrawTask!=null){                            myDrawTask.cancel(false);                    }            }            @OverrIDe            public voID onOffsetsChanged(float xOffset, float yOffset, float xStep,            float yStep, int xPixels, int yPixels) {                    mXOffset = xOffset;                    mYOffset = yOffset;                    if(myDrawTask!=null){                            myDrawTask.cancel(false);                    }                    myDrawTask = new DrawTask(getSurfaceHolder(), mPaint);                    myDrawTask.execute();            }            @OverrIDe            public voID ontouchEvent(MotionEvent event) {                    super.ontouchEvent(event);                    this.doubleTapDetector.ontouchEvent(event);            }            public final Bitmap drawabletoBitmap(Drawable drawable) {                    int targetWIDth = (mScroll) ? mMinWIDth : dss.getWIDth();                    int targetHeight = (mScroll) ? mMinHeight : dss.getHeight();                    Bitmap bitmap = Bitmap.createBitmap(targetWIDth, targetHeight, Config.ARGB_8888);                    Canvas canvas = new Canvas(bitmap);                    drawable.setBounds(0, 0, canvas.getWIDth(), canvas.getHeight());                    drawable.draw(canvas);                    // Rotate                    .....................                    // Scale bitmap                    .....................                    return bitmap;            }            voID getScreenSize() {                    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);                    display d = wm.getDefaultdisplay();                    displayMetrics metrics = new displayMetrics();                    d.getMetrics(metrics);                    // since SDK_INT = 1;                    dss.setDeviceScreenParams(metrics.wIDthPixels, metrics.heightPixels, metrics.densityDpi);                    // includes window decorations (statusbar bar/menu bar)                    if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)                            try {                                    dss.setDeviceScreenParams((Integer) display.class.getmethod("getRawWIDth").invoke(d), (Integer) display.class.getmethod("getRawHeight").invoke(d), metrics.densityDpi);                            } catch (Exception ignored) {}                    // includes window decorations (statusbar bar/menu bar)                    if (Build.VERSION.SDK_INT >= 17)                            try {                                    displayMetrics realSize = new displayMetrics();                                    display.class.getmethod("getRealMetrics", displayMetrics.class).invoke(d, realSize);                                    dss.setDeviceScreenParams(realSize.wIDthPixels, realSize.heightPixels, realSize.densityDpi);                            } catch (Exception ignored) {}            }            //            // ************************            // DRAW AND ANIMATION TASK            // ************************            //            public class DrawTask extends AsyncTask<VoID, VoID, VoID> {                    private final SurfaceHolder _surfaceHolder;                    private Paint myPaint;                    boolean CancelFlag = false, stopAnimationFlag = false;                    //HANDLERS                    private final Handler mDrawHandler = new Handler(){                            public voID handleMessage(androID.os.Message msg) { };                    };                    //WORKERS                    private final Runnable mDrawWorker = new Runnable() {                            public voID run() {                                    if (mDuration > 0)                                    {                                            drawFrame();                                    }                            }                    };                    DrawTask(SurfaceHolder holder, Paint paint){                            _surfaceHolder = holder;                            myPaint = paint;                            CancelFlag = false;                    }                    SurfaceHolder getSurfHolder(){                            return _surfaceHolder;                    }                    Paint getPaint(){                            return myPaint;                    }                    @OverrIDe                    protected voID onPreExecute() {                            super.onPreExecute();                    }                       @OverrIDe                    protected VoID doInBackground(VoID... params) {                            drawFrame();                            while(!CancelFlag){}                            return null;                    }                    @OverrIDe                    protected voID onPostExecute(VoID result) {                            // Todo auto-generated method stub                            super.onPostExecute(result);                    }                    @OverrIDe                    protected voID onCancelled() {                            // Todo auto-generated method stub                            super.onCancelled();                            CancelFlag = true;                    }                    voID drawFrame() {                            final SurfaceHolder holder = _surfaceHolder;                            Canvas c = null;                            boolean getimage = false;                            try {                                    // Lock the canvas for writing                                    c = holder.lockCanvas();                                    // Do we need to get a new image?                                    if (mBitmap == null) {                                            getimage = true;                                    } else if (mDuration > 0 && mLastDrawTime < System.currentTimeMillis() - mDuration) {                                            getimage = true;                                    } else if (mLastDrawTime == 0) {                                            getimage = true;                                    }                                    // Get image to draw                                    if (getimage) {                                            // Get a List of files                                            String[] assets_files = null;                                            try {                                                    assets_files = getApplicationContext().getAssets().List("");                                            } catch (IOException e) {                                                    e.printstacktrace();                                            }                                            List<String> str_List = new ArrayList<String>();                                            for (int fi = 0; fi < assets_files.length; fi++) {                                                    String ext = BitmapUtil.getExtension(assets_files[fi]);                                                    if (ext != null) {                                                            if (ext.equals("jpg") || ext.equals("jpeg") || ext.equals("png") || ext.equals("gif")) {                                                                    str_List.add(assets_files[fi]);                                                            }                                                    }                                            }                                            assets_files = str_List.toArray(new String[str_List.size()]);                                            // Increment counter                                            int nfiles = assets_files.length;                                            if (mRandom) {                                                    int i = mIndex;                                                    do {                                                            mIndex = (int) (Math.random() * nfiles);                                                    } while (nfiles > 1 && mIndex == i);                                            } else {                                                    if (++mIndex >= nfiles) {                                                            mIndex = 0;                                                    }                                            }                                            inputStream ims = null;                                            try {                                                    ims = getAssets().open(assets_files[mIndex]);                                            } catch (IOException e) {                                                    e.printstacktrace();                                            }                                            d = Drawable.createFromStream(ims, null);                                            // Read file to bitmap                                            mBitmap=null;                                            mBitmap = drawabletoBitmap(d);                                            // Save the current time                                            mLastDrawTime = System.currentTimeMillis();                                    } else if (mBitmap != null && mBitmap.isRecycled()){                                            mBitmap=null;                                            mBitmap = drawabletoBitmap(d);                                    }                            } catch (NullPointerException npe) {                                    holder.unlockCanvasAndPost(c);                                    return;                            } catch (RuntimeException re) {                                    holder.unlockCanvasAndPost(c);                                    return;                            }                            try {                                    if (c != null) {                                            int xPos;                                            int yPos;                                            if (mScroll) {                                                    xPos = 0 - (int) (mWIDth * mXOffset);                                                    yPos = 0 - (int) (mHeight * mYOffset);                                            } else {                                                    xPos = 0;                                                    yPos = 0;                                            }                                            try {                                                    c.drawcolor(color.BLACK);                                                    c.drawBitmap(mBitmap, xPos, yPos, myPaint);                                                    } catch (Throwable t) {}                                    }                            } finally {                                    if (c != null){                                            if((mPrevIoUsBitmap==null) || (mPrevIoUsBitmap==mBitmap))                                                    holder.unlockCanvasAndPost(c);                                            else{                                                                           if(mTransition!=0)                                                            startAnimation(mTransition, holder, c);                                                    else                                                            holder.unlockCanvasAndPost(c);                                            }                                                    mPrevIoUsBitmap=null;                                                    mPrevIoUsBitmap = mBitmap;                                    }                            }                            // Reschedule the next redraw                            mDrawHandler.removeCallbacks(mDrawWorker);                            if (mVisible) {                                    mDrawHandler.postDelayed(mDrawWorker, 1000 / 2);                            }                            else{CancelFlag=true;}                    }                    voID startAnimation(int animNumber, SurfaceHolder holder, Canvas canvas)                    {                            switch(animNumber){                                    case 1:{                                            canvas.drawBitmap(mBitmap, 0, 0, myPaint);                                            int tmpPaintAlpha = myPaint.getAlpha();                                            myPaint.setAlpha(255);                                            canvas.drawBitmap(mPrevIoUsBitmap, 0, 0, myPaint);                                            holder.unlockCanvasAndPost(canvas);                                            myPaint.setAlpha(tmpPaintAlpha);                                            int i=224;                                            while(i>=0){                                                    canvas = holder.lockCanvas();                                                    canvas.drawBitmap(mBitmap, 0, 0, myPaint);                                                    myPaint.setAlpha(i);                                                    canvas.drawBitmap(mPrevIoUsBitmap, 0, 0, myPaint);                                                    holder.unlockCanvasAndPost(canvas);                                                    myPaint.setAlpha(255);                                                    i-=18;                                            }                                            mLastDrawTime=System.currentTimeMillis();                                            break;                                    }                                    case 2:{                                            ....................                                            break;                                    }                            }                    }            }    ...................    }    ...................}

每当我们陷入DrawTask.drawFrame()方法时,即使没有任何通知(mTransition == 0),每次都会发生错误.结果,我看到了:

(1)正确完成初始图像和下一个图像的第一步;

(2)当需要将第二张图像转换为第三张图像时,我只是在不固定的时间段内看到黑屏,然后再次看到我的初始图像并无限重复上述(2).设置的任何更改都不会更改此行为.

UPD3希望我对此问题的详细描述(UPD1,UPD2)可以帮助找到这种奇怪行为的原因.但是,不幸的是,现在不适合我.

预先感谢!

解决方法:

SIGSTKFLT在设备内存不足(尤其是内存不足)时发生.在底层linux OS层中使用malloc()调用时.当OS无法在malloc中返回失败时,它将生成这种致命信号.

当处理图像占用大量内存时,请尝试使用一些内存节省技术(例如后期绑定图像解码)来解决低内存设备上的上述问题.

首先,您可以尝试将图像重新调整为屏幕分辨率或更低的尺寸,然后再将其发布到画布上.

总结

以上是内存溢出为你收集整理的致命错误信号16(SIGSTKFLT)已意外发生全部内容,希望文章能够帮你解决致命错误信号16(SIGSTKFLT)已意外发生所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1095429.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存