Category Archives: Error

Android 10 SurfaceView Crash: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4

Recently, it was found that SurfaceView crashed during the test on Android 10 system. The system tests before 10 will crash, but it is normal on devices after Android 11.

Error log

Native error message

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
Cause: null pointer dereference
    eax 00000000  ebx f017756c  ecx 00000001  edx 00017af6
    edi 00017af6  esi edbe9140
    ebp c4c67938  esp c4c67920  eip f0169a71

backtrace:
      #00 pc 0000fa71  /system/lib/libutils.so (android::RefBase::incStrong(void const*) const+33) (BuildId: 288ba3aff5b46dbd7e74be954af88b83)
      #01 pc 00114620  /system/lib/libandroid_runtime.so (android::nativeDeferTransactionUntilSurface(_JNIEnv*, _jclass*, long long, long long, long long, long long)+96) (BuildId: 3643bee2c4fb7899d7781c565843060b)
      #02 pc 002a2325  /system/framework/x86/boot-framework.oat (art_jni_trampoline+213) (BuildId: 38176ebc9c3cce5f657a723b08d40d487952c484)
      #03 pc 0204d399  /memfd:/jit-cache (deleted) (android.view.SurfaceControl.access$2700+89)
      #04 pc 020421aa  /memfd:/jit-cache (deleted) (android.view.SurfaceControl$Transaction.deferTransactionUntilSurface+202)
      #05 pc 02036db1  /memfd:/jit-cache (deleted) (android.view.SurfaceView.applySurfaceTransforms+177)
      #06 pc 0204979f  /memfd:/jit-cache (deleted) (android.view.SurfaceView.setParentSpaceRectangle+95)
      #07 pc 020546cb  /memfd:/jit-cache (deleted) (android.view.SurfaceView.access$200+59)
      #08 pc 0204ae12  /memfd:/jit-cache (deleted) (android.view.SurfaceView$3.positionChanged+434)
      #09 pc 0203c004  /memfd:/jit-cache (deleted) (android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged+148)

Error messages displayed in the application layer log

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10 in tid 6711 (hwuiTask0), pid 6669 (.crash)
Exception from repositionChild
    java.lang.NullPointerException: mNativeObject is null. Have you called release() already?
            at android.view.SurfaceControl.checkNotReleased(SurfaceControl.java:945)
            at android.view.SurfaceControl.access$800(SurfaceControl.java:77)
            at android.view.SurfaceControl$Transaction.setPosition(SurfaceControl.java:2170)
            at android.view.SurfaceView.applySurfaceTransforms(SurfaceView.java:1025)
            at android.view.SurfaceView.setParentSpaceRectangle(SurfaceView.java:1038)
            at android.view.SurfaceView.access$200(SurfaceView.java:99)
            at android.view.SurfaceView$1.positionChanged(SurfaceView.java:1081)

Find a relevant Google patch on the Internet according to the error information

commit	005c63e8c6e6e5b312dc9c4631c57fb12224df30	[log] [tgz]
author	Robert Carr <[email protected]>	Fri Sep 20 14:31:24 2019 -0700
committer	Robert Carr <[email protected]>	Fri Sep 20 14:48:40 2019 -0700
tree	939eaeca0159a44bca7b5abf44f41f5096c1fb90
parent	c48da419931a3a9272910f2631f815cecf05c9ba [diff]
SurfaceView: Destroy SurfaceControl from RenderThread

Currently there is a race where the UI thread can destroy
the SurfaceControl (free the C++ object) while the RenderThread
still has pending operations on it. To fix have the positionLost callback handle the destruction.

Bug: 139111930
Bug: 136808018
Test: go/wm-smoke
Change-Id: Id5225e1e47046d928f8298de38ff61662debe360
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 90e69f3..262b9e5 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -136,6 +136,7 @@
     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
     boolean mIsCreating = false;
     private volatile boolean mRtHandlingPositionUpdates = false;
+    private volatile boolean mRtReleaseSurfaces = false;
 
     private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener =
             this::updateSurface;
@@ -658,7 +659,14 @@
     }
 
     private void releaseSurfaces() {
+        mSurfaceAlpha = 1f;
+
         synchronized (mSurfaceControlLock) {
+            if (mRtHandlingPositionUpdates) {
+                mRtReleaseSurfaces = true;
+                return;
+            }
+
             if (mSurfaceControl != null) {
                 mTmpTransaction.remove(mSurfaceControl);
                 mSurfaceControl = null;
@@ -669,7 +677,6 @@
             }
             mTmpTransaction.apply();
         }
-        mSurfaceAlpha = 1f;
     }
 
     /** @hide */
@@ -1084,7 +1091,9 @@
             // the synchronization would violate the rule that RT must never block
             // on the UI thread which would open up potential deadlocks. The risk of
             // a single-frame desync is therefore preferable for now.
-            mRtHandlingPositionUpdates = true;
+            synchronized(mSurfaceControlLock) {
+                mRtHandlingPositionUpdates = true;
+            }
             if (mRTLastReportedPosition.left == left
                     && mRTLastReportedPosition.top == top
                     && mRTLastReportedPosition.right == right
@@ -1126,6 +1135,18 @@
                         frameNumber);
             }
             mRtTransaction.hide(mSurfaceControl);
+
+            synchronized (mSurfaceControlLock) {
+                if (mRtReleaseSurfaces) {
+                    mRtReleaseSurfaces = false;
+                    mRtTransaction.remove(mSurfaceControl);
+                    mRtTransaction.remove(mBackgroundControl);
+                    mSurfaceControl = null;
+                    mBackgroundControl = null;
+                }
+                mRtHandlingPositionUpdates = false;
+            }
+
             mRtTransaction.apply();
         }
     };

After updating, the SurfaceView getViewRootImpl() will always be empty. No patches for other updates were found
Because it is normal to test on Android 11, Android 11 solves this problem, so directly copy the code of Android 11’s SurfaceView. Because Android 11 has updated a lot of things, select relevant modifications to update.

diff --git a/frameworks/base/core/java/android/view/SurfaceView.java b/frameworks/base/core/java/android/view/SurfaceView.java
index d11548d687..3d1a5a3549 100644
--- a/frameworks/base/core/java/android/view/SurfaceView.java
+++ b/frameworks/base/core/java/android/view/SurfaceView.java
@@ -118,8 +118,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
     boolean mDrawFinished = false;

     final Rect mScreenRect = new Rect();
-    SurfaceSession mSurfaceSession;
-
+    private final SurfaceSession mSurfaceSession = new SurfaceSession();
     SurfaceControl mSurfaceControl;
     // In the case of format changes we switch out the surface in-place
     // we need to preserve the old one until the new one has drawn.
@@ -135,6 +134,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
     boolean mIsCreating = false;
     private volatile boolean mRtHandlingPositionUpdates = false;
+    private volatile boolean mRtReleaseSurfaces = false;

     private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener =
             this::updateSurface;
@@ -428,9 +428,16 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
     }

     private void performDrawFinished() {
+        if (mDeferredDestroySurfaceControl != null) {
+            synchronized (mSurfaceControlLock) {
+                mTmpTransaction.remove(mDeferredDestroySurfaceControl).apply();
+                mDeferredDestroySurfaceControl = null;
+            }
+        }
         if (mPendingReportDraws > 0) {
             mDrawFinished = true;
             if (mAttachedToWindow) {
+                mParent.requestTransparentRegion(SurfaceView.this);
                 notifyDrawFinished();
                 invalidate();
             }
@@ -658,7 +665,15 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
     }

     private void releaseSurfaces() {
+        mSurfaceAlpha = 1f;
+
         synchronized (mSurfaceControlLock) {
+            mSurface.release();
+            if (mRtHandlingPositionUpdates) {
+                mRtReleaseSurfaces = true;
+                return;
+            }
+
             if (mSurfaceControl != null) {
                 mTmpTransaction.remove(mSurfaceControl);
                 mSurfaceControl = null;
@@ -669,7 +684,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
             }
             mTmpTransaction.apply();
         }
-        mSurfaceAlpha = 1f;
     }

     /** @hide */
@@ -680,12 +694,21 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
             }
             return;
         }
-        ViewRootImpl viewRoot = getViewRootImpl();
-        if (viewRoot == null || viewRoot.mSurface == null || !viewRoot.mSurface.isValid()) {
+        final ViewRootImpl viewRoot = getViewRootImpl();
+        if (viewRoot == null) {
+            if (DEBUG) {
+                Log.d(TAG, System.identityHashCode(this)
+                        + " updateSurface: viewRoot null");
+            }
+            return;
+        }
+        if (viewRoot.mSurface == null || !viewRoot.mSurface.isValid()) {
             if (DEBUG) {
                 Log.d(TAG, System.identityHashCode(this)
                         + " updateSurface: no valid surface");
             }
+            notifySurfaceDestroyed();
+            releaseSurfaces();
             return;
         }

@@ -708,9 +731,14 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
         final boolean sizeChanged = mSurfaceWidth != myWidth || mSurfaceHeight != myHeight;
         final boolean windowVisibleChanged = mWindowVisibility != mLastWindowVisibility;
         boolean redrawNeeded = false;
-
-        if (creating || formatChanged || sizeChanged || visibleChanged || (mUseAlpha
-                && alphaChanged) || windowVisibleChanged) {
+        getLocationInSurface(mLocation);
+        final boolean positionChanged = mWindowSpaceLeft != mLocation[0]
+            || mWindowSpaceTop != mLocation[1];
+        final boolean layoutSizeChanged = getWidth() != mScreenRect.width()
+            || getHeight() != mScreenRect.height();
+        if (creating || formatChanged || sizeChanged || visibleChanged ||
+                (mUseAlpha && alphaChanged) || windowVisibleChanged ||
+                positionChanged || layoutSizeChanged) {
             getLocationInWindow(mLocation);

             if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " "
@@ -744,7 +772,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb

                 if (creating) {
                     viewRoot.createBoundsSurface(mSubLayer);
-                    mSurfaceSession = new SurfaceSession();
                     mDeferredDestroySurfaceControl = mSurfaceControl;

                     updateOpaqueFlag();
@@ -853,28 +880,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
                     final boolean surfaceChanged = creating;
                     if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
                         mSurfaceCreated = false;
-                        if (mSurface.isValid()) {
-                            if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " "
-                                    + "visibleChanged -- surfaceDestroyed");
-                            callbacks = getSurfaceCallbacks();
-                            for (SurfaceHolder.Callback c : callbacks) {
-                                c.surfaceDestroyed(mSurfaceHolder);
-                            }
-                            // Since Android N the same surface may be reused and given to us
-                            // again by the system server at a later point. However
-                            // as we didn't do this in previous releases, clients weren't
-                            // necessarily required to clean up properly in
-                            // surfaceDestroyed. This leads to problems for example when
-                            // clients don't destroy their EGL context, and try
-                            // and create a new one on the same surface following reuse.
-                            // Since there is no valid use of the surface in-between
-                            // surfaceDestroyed and surfaceCreated, we force a disconnect,
-                            // so the next connect will always work if we end up reusing
-                            // the surface.
-                            if (mSurface.isValid()) {
-                                mSurface.forceScopedDisconnect();
-                            }
-                        }
+                        notifySurfaceDestroyed();
                     }

                     if (creating) {
@@ -933,7 +939,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
                 } finally {
                     mIsCreating = false;
                     if (mSurfaceControl != null && !mSurfaceCreated) {
-                        mSurface.release();
                         releaseSurfaces();
                     }
                 }
@@ -944,48 +949,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
                 TAG, "Layout: x=" + mScreenRect.left + " y=" + mScreenRect.top
                 + " w=" + mScreenRect.width() + " h=" + mScreenRect.height()
                 + ", frame=" + mSurfaceFrame);
-        } else {
-            // Calculate the window position in case RT loses the window
-            // and we need to fallback to a UI-thread driven position update
-            getLocationInSurface(mLocation);
-            final boolean positionChanged = mWindowSpaceLeft != mLocation[0]
-                    || mWindowSpaceTop != mLocation[1];
-            final boolean layoutSizeChanged = getWidth() != mScreenRect.width()
-                    || getHeight() != mScreenRect.height();
-            if (positionChanged || layoutSizeChanged) { // Only the position has changed
-                mWindowSpaceLeft = mLocation[0];
-                mWindowSpaceTop = mLocation[1];
-                // For our size changed check, we keep mScreenRect.width() and mScreenRect.height()
-                // in view local space.
-                mLocation[0] = getWidth();
-                mLocation[1] = getHeight();
-
-                mScreenRect.set(mWindowSpaceLeft, mWindowSpaceTop,
-                        mWindowSpaceLeft + mLocation[0], mWindowSpaceTop + mLocation[1]);
-
-                if (translator != null) {
-                    translator.translateRectInAppWindowToScreen(mScreenRect);
-                }
-
-                if (mSurfaceControl == null) {
-                    return;
-                }
-
-                if (!isHardwareAccelerated() || !mRtHandlingPositionUpdates) {
-                    try {
-                        if (DEBUG_POSITION) {
-                            Log.d(TAG, String.format("%d updateSurfacePosition UI, "
-                                            + "position = [%d, %d, %d, %d]",
-                                    System.identityHashCode(this),
-                                    mScreenRect.left, mScreenRect.top,
-                                    mScreenRect.right, mScreenRect.bottom));
-                        }
-                        setParentSpaceRectangle(mScreenRect, -1);
-                    } catch (Exception ex) {
-                        Log.e(TAG, "Exception configuring surface", ex);
-                    }
-                }
-            }
         }
     }

@@ -994,12 +957,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
             Log.i(TAG, System.identityHashCode(this) + " "
                     + "finishedDrawing");
         }
-
-        if (mDeferredDestroySurfaceControl != null) {
-            mTmpTransaction.remove(mDeferredDestroySurfaceControl).apply();
-            mDeferredDestroySurfaceControl = null;
-        }
-
         runOnUiThread(this::performDrawFinished);
     }

@@ -1015,9 +972,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
     }

     private void applySurfaceTransforms(SurfaceControl surface, Rect position, long frameNumber) {
-        if (frameNumber > 0) {
-            final ViewRootImpl viewRoot = getViewRootImpl();
-
+        final ViewRootImpl viewRoot = getViewRootImpl();
+        if (frameNumber > 0 && viewRoot != null ) {
             mRtTransaction.deferTransactionUntilSurface(surface, viewRoot.mSurface,
                     frameNumber);
         }
@@ -1036,10 +992,10 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
         final ViewRootImpl viewRoot = getViewRootImpl();

         applySurfaceTransforms(mSurfaceControl, position, frameNumber);
-
-        applyChildSurfaceTransaction_renderWorker(mRtTransaction, viewRoot.mSurface,
+        if (frameNumber > 0 && viewRoot != null ) {
+            applyChildSurfaceTransaction_renderWorker(mRtTransaction, viewRoot.mSurface,
                 frameNumber);
-
+        }
         mRtTransaction.apply();
     }

@@ -1062,7 +1018,9 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
             // the synchronization would violate the rule that RT must never block
             // on the UI thread which would open up potential deadlocks. The risk of
             // a single-frame desync is therefore preferable for now.
-            mRtHandlingPositionUpdates = true;
+            synchronized(mSurfaceControlLock) {
+                mRtHandlingPositionUpdates = true;
+            }
             if (mRTLastReportedPosition.left == left
                     && mRTLastReportedPosition.top == top
                     && mRTLastReportedPosition.right == right
@@ -1096,14 +1054,27 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
             if (mSurfaceControl == null) {
                 return;
             }
+            final ViewRootImpl viewRoot = getViewRootImpl();

-            if (frameNumber > 0) {
-                final ViewRootImpl viewRoot = getViewRootImpl();

-                mRtTransaction.deferTransactionUntilSurface(mSurfaceControl, viewRoot.mSurface,
-                        frameNumber);
+            synchronized (mSurfaceControlLock) {
+                if (frameNumber > 0 && viewRoot != null) {
+                    if (viewRoot.mSurface.isValid()) {
+                        mRtTransaction.deferTransactionUntilSurface(mSurfaceControl, viewRoot.mSurface,
+                                frameNumber);
+                                       }
+                }
+                mRtTransaction.hide(mSurfaceControl);
+                if (mRtReleaseSurfaces) {
+                    mRtReleaseSurfaces = false;
+                    mRtTransaction.remove(mSurfaceControl);
+                    mRtTransaction.remove(mBackgroundControl);
+                    mSurfaceControl = null;
+                    mBackgroundControl = null;
+                }
+                mRtHandlingPositionUpdates = false;
             }
-            mRtTransaction.hide(mSurfaceControl);
+
             mRtTransaction.apply();
         }
     };
@@ -1348,4 +1319,29 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
     public SurfaceControl getSurfaceControl() {
         return mSurfaceControl;
     }
+
+    private void notifySurfaceDestroyed() {
+        if (mSurface.isValid()) {
+            if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " "
+                    + "surfaceDestroyed");
+            SurfaceHolder.Callback[] callbacks = getSurfaceCallbacks();
+            for (SurfaceHolder.Callback c : callbacks) {
+                c.surfaceDestroyed(mSurfaceHolder);
+            }
+            // Since Android N the same surface may be reused and given to us
+            // again by the system server at a later point. However
+            // as we didn't do this in previous releases, clients weren't
+            // necessarily required to clean up properly in
+            // surfaceDestroyed. This leads to problems for example when
+            // clients don't destroy their EGL context, and try
+            // and create a new one on the same surface following reuse.
+            // Since there is no valid use of the surface in-between
+            // surfaceDestroyed and surfaceCreated, we force a disconnect,
+            // so the next connect will always work if we end up reusing
+            // the surface.
+            if (mSurface.isValid()) {
+                mSurface.forceScopedDisconnect();
+            }
+        }
+    }
 }

After modification, the test is normal, and the application will not crash, but an error log message will pop up from time to time
E/Layer: [SurfaceView – com. crash/com. crash. MainActivity # 3] No local sync point found

Check Layer.cpp when encountering this exception is to skip the logic, so it does not care, it is not clear if there are any other problems with this change.

 741 bool Layer::applyPendingStates(State* stateToCommit) {
 742     bool stateUpdateAvailable = false;
 743     while (!mPendingStates.empty()) {
 744         if (mPendingStates[0].barrierLayer_legacy != nullptr) {
 745             if (mRemoteSyncPoints.empty()) {
 746                 // If we don't have a sync point for this, apply it anyway. It
 747                 // will be visually wrong, but it should keep us from getting
 748                 // into too much trouble.
 749                 ALOGE("[%s] No local sync point found", mName.string());
 750                 popPendingState(stateToCommit);
 751                 stateUpdateAvailable = true;
 752                 continue;
 753             }
 754
 755             if (mRemoteSyncPoints.front()->getFrameNumber() !=
 756                 mPendingStates[0].frameNumber_legacy) {
 757                 ALOGE("[%s] Unexpected sync point frame number found", mName.string());
 758
 759                 // Signal our end of the sync point and then dispose of it
 760                 mRemoteSyncPoints.front()->setTransactionApplied();
 761                 mRemoteSyncPoints.pop_front();
 762                 continue;
 763             }
 764
 765             if (mRemoteSyncPoints.front()->frameIsAvailable()) {
 766                 ATRACE_NAME("frameIsAvailable");
 767                 // Apply the state update
 768                 popPendingState(stateToCommit);
 769                 stateUpdateAvailable = true;
 770
 771                 // Signal our end of the sync point and then dispose of it
 772                 mRemoteSyncPoints.front()->setTransactionApplied();
 773                 mRemoteSyncPoints.pop_front();
 774             } else {
 775                 ATRACE_NAME("!frameIsAvailable");
 776                 break;
 777             }
 778         } else {
 779             popPendingState(stateToCommit);
 780             stateUpdateAvailable = true;
 781         }
 782     }
 783
 784     // If we still have pending updates, wake SurfaceFlinger back up and point
 785     // it at this layer so we can process them
 786     if (!mPendingStates.empty()) {
 787         setTransactionFlags(eTransactionNeeded);
 788         mFlinger->setTransactionFlags(eTraversalNeeded);
 789     }
 790
 791     mCurrentState.modified = false;
 792     return stateUpdateAvailable;
 793 }

EF core Creates pg library and Model Report an Error [Solved]

PM> Scaffold-DbContext "server=localhost;database=SimulationDatabase;uid=postgres;pwd=123456;port=5432;" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir PgModel -Force
Build started...
Build succeeded.
To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
Npgsql.PostgresException (0x80004005): 3D000: ���ݿ� "SimulationDatabase" ������
   at Npgsql.Internal.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|215_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|195_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
   at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.ConnectorPool.<Get>g__RentAsync|28_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnection.Open()
   at Npgsql.EntityFrameworkCore.PostgreSQL.Scaffolding.Internal.NpgsqlDatabaseModelFactory.Create(DbConnection dbConnection, DatabaseModelFactoryOptions options)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Scaffolding.Internal.NpgsqlDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  Exception data:
    Severity: ��������
    SqlState: 3D000
    MessageText: ���ݿ� "SimulationDatabase" ������
    File: d:\pginstaller_12.auto\postgres.windows-x64\src\backend\utils\init\postinit.c
    Line: 879
    Routine: InitPostgres
3D000: ���ݿ� "SimulationDatabase" ������

 

Solution:

PM> Scaffold-DbContext "Host=localhost; Port=5432 ;Database=simulation;Username=postgres;Password=123456" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir PostgreSqlModels -Context DBContext -force
Build started...
Build succeeded.
To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.

torchvision.dataset Failed to Download CIFAR10 Error [How to Solve]

An error occurred while using dataset to download the dataset

urllib.error.URLError:urlopen error unknown url type:https 

Considering that there is no import ssl, add the following command

**import ssl
ssl._create_default_https_context = ssl._create_unverified_context**

Run again to import ssl

import ssl report an error: DLL load fail error

Solution:

First, configure the environment variable, find the current python installation directory, and add the following three paths to the PATH of the system variable

**E:\Anaconda3\envs\pytorch;      #python.exe所在路径
  E:\Anaconda3\envs\pytorch\Scripts;		
  E:\Anaconda3\envs\pytorch\Library\bin**

Then find the files libcrypto-1_1.dll and libssl-1_1.dll in the bin folder and copy them to the DLLs path.

This solves the download problem

[SteamVR] Not Initialized (109) Error [How to Solve]

[SteamVR] Not Initialized (109)

[SteamVR] Initialization failed. Please verify that you have SteamVR installed, your hmd is functioning, and OpenVR Loader is checked in the XR Plugin Management section of Project Settings.

VR equipment: HTC VIVE COSMOS

VR plug-in: SteamVR Plugin 2.7.3

Unit version: 2019.4.40f1

Error reporting scenario:

Each time you close unity, reopen it. Run the project and then report an error.

Solution:

Reopen the Project Setting panel of unity engine and close it. The error is solved. (unity menu bar find Editor->Project Settings, open, click the fork to close the panel). Because I am using git to do version control, I found that some oid in the file ProjectSettings.asset will change every time I report an error, so I thought it was related to Project Settings. I tried reopening the Project Settings panel and it worked. If you are using git to do version control, you can try to recover the ProjectSettings.asset file to solve the bug.

[Solved] Spark Error: org.apache.spark.SparkException: A master URL must be set in your configuration

Error when running the project to connect to Spark:

Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
22/10/08 21:02:10 INFO SparkContext: Running Spark version 3.0.0
22/10/08 21:02:10 ERROR SparkContext: Error initializing SparkContext.
org.apache.spark.SparkException: A master URL must be set in your configuration
	at org.apache.spark.SparkContext.<init>(SparkContext.scala:380)
	at org.apache.spark.SparkContext.<init>(SparkContext.scala:120)
	at test.wyh.wordcount.TestWordCount$.main(TestWordCount.scala:10)
	at test.wyh.wordcount.TestWordCount.main(TestWordCount.scala)
22/10/08 21:02:10 INFO SparkContext: Successfully stopped SparkContext
Exception in thread "main" org.apache.spark.SparkException: A master URL must be set in your configuration
	at org.apache.spark.SparkContext.<init>(SparkContext.scala:380)
	at org.apache.spark.SparkContext.<init>(SparkContext.scala:120)
	at test.wyh.wordcount.TestWordCount$.main(TestWordCount.scala:10)
	at test.wyh.wordcount.TestWordCount.main(TestWordCount.scala)

Process finished with exit code 1

Solution:

Configure the following parameters:

-Dspark.master=local[*]

Restart IDEA.

Win10 System migrate and restart error 0xc000000e [How to Solve]

Background

When migrating (cloning) the system to a new SSD and using the DiskGenius tool to complete the system migration, the last step reports an error, “Error in starting update parameters.”. When using a new solid state startup, the error 0xc000000e is reported.

Environment

Microsoft Windows [Version 10.0.19043.2006] Microsoft DiskPart Version 10.0.19041.964

Preparation

Prepare a removable storage disk (U disk, removable hard disk, pssd) with the official Win10 system installation media.

Solution:

  1. Insert a new solid state into the motherboard
  2. When booting, use the Win10 installation media disk as the boot disk, select “Repair Windows” and find the “Command Prompt”.
  3. Go to diskpart to get the disk letter and disk ID
diskpart
      1. List the attached disks, obtain the disk number of the system file, and record it as N (Number)
DISKPART> list disk

View the volume list, obtain the drive letter of the system file, mark it as C (Char)

Select the disk, and obtain the disk ID

DISKPART> select disk N
DISKPART> uniqueid disk

N is the disk number mentioned above

Exit diskpart

DISKPART> exit

If you cannot exit by typing exit on the command line, use Ctrl+c

Reassign the disk ID corresponding to the drive letter

bcdboot c:\windows /l zh-cn
bcdboot c:\windows /m {73B9D7DD-59F7-4483-8B77-EED47E457C18}

C is the drive letter C mentioned above

{73B9D7DD-59F7-4483-8B77-EED47E457C18} is the disk ID mentioned above

Close the command prompt and restart

[Solved] Android OkHttp Error: java.net.UnknownServiceException

Question

When using OkHttp to request an http address on Android 9.0 mobile phones, the following error will be reported:

java.net. UnknownServiceException: CLEARTEXT communication to **** not permitted by network security policy

The reason is that after Android 9.0, Google officially explained:

In order to ensure the security of user data and devices, Google will require encrypted connections by default for applications of the next generation Android system (Android P), which means that
Android P will prohibit apps from using all unencrypted connections. Therefore, Android devices running Android P
systems will not be able to send or receive traffic plainly in the future.

Solutions (Three Methods):

  1. APP change to https request
  2. argetSdkVersion lowered to below 27 change
  3. Network security configuration

 

The Third Method

Create an xml folder under the res folder, then create a network_security_config.xml file in the xml directory with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>             
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

Add properties to the application tag under the AndroidManifest.xml file

android:networkSecurityConfig="@xml/network_security_config"

After configuration, you can access the http address.

[Solved] UE4 Android Package Error: cmd.exe failed with args

Edition:

UE4.27.2, Android Studio 4.0, Window system

Error content:

ERROR: cmd. exe failed with args /…….

Execution failed for task ‘:app:compileDebugJavaWithJavac’

> Compilation failed; see the compiler error output for details.

Solution:

This type of error reporting is general, JAVA-related error reporting, the red letter will only give cmd.exe failed with args, only search the line of error is unable to find the problem.

Error log to turn up, find * What went wrong:, the next two lines of the line is the real content of the error report.

In my personal case, the specific error is

Execution failed for task ‘:app:compileDebugJavaWithJavac’.

> Compilation failed; see the compiler error output for details.

The problem is caused by the inconsistency between the JDK version selected by UE4 and the JDK version in the system environment variable, either modify the JDK version selected by UE4 or modify the system environment variable.

The former: Edit->Project Settings->Android SDK->Location of JAVA, select the same JDK directory as your environment variable, and go to Edit->Project Settings->Android, you need to click Configure Now again.

The latter: open the system environment variables, find JAVA_HOME in the system variables, edit and modify it to the JDK version selected by UE4; find Path, double click to open it, find C:\Program Files (x86)\Common Files\Oracle\Java\javapath this line, copy the address, open it in the folder and delete the 3 JAVA files in it. Finally, open CMD and type java -version to test if the replacement has been completed.

[Solved] mybatis plus Error: Invalid bound statement (not found)

Some students encountered the problem of “Invalid bound statement (not found)” when building the mybatis plus project, it is essentially that the mapper interface and the mapper.xml is not mapped.

In this case, the common problems are as follows:

1, mapper.xml inside the namespace and the actual mapper class path is not consistent.
There is a quick way to detect this is to hold down the ctrl key, and then click the package name inside the namespace, if you can jump to the corresponding class, it means there is no problem, if you use the IDEA is the same way, IDEA package name can be segmented, as long as you can point in are no problem.

2, mapper interface function name and mapper.xml inside the label id is not consistent.
This problem is also very common, the best way is to paste and copy it, so as to ensure that there is no problem.

The first point and 2 points are about spelling errors.

3, the build did not go in, please see if these exist below the target folder, no please rebuild

4. Check whether package scanning is added. I added it to the spring boot startup class.

5. Check whether the configuration file is written incorrectly or not

#Is this place wrongly written?

mapper-locations: classpath:mybatis/mapper/**/*.xml

Mybatis-plus can be configured as an array:

mybatis-plus:
  mapper-locations:
    - classpath:mybatis/mapper/**/*.xml

Or

mybatis-plus:
  mapper-locations: classpath:mybatis/**/*Mapper.xml

Note that the key is mapper-locations and not mapper-locations:

Other configurations:


mybatis-plus:
  global-config:
    #primary-key-type 0: "Database ID self-incrementing", 1: "User input ID", 2: "Global unique ID (numeric unique ID)", 3: "Global unique ID UUID";
    id-type: 0
    #field-strategy 0: "Ignore judgment",1: "Non-NULL judgment"),2: "Non-Null judgment"
    field-strategy: 0
    #hump-underline conversion
    db-column-underline: true
    #refresh-mapper debugging artifact
    refresh-mapper: true
    #database capital-underline conversion
    #capital-mode: true 
    #sequence interface implementation class configuration    
	#key-generator: com.baomidou.springboot.xxx 
    #logic-delete-configuration (the following 3 configurations)
    #logic-delete-value: 0 # logical-delete value (default is 1)    
	#logic-not-delete-value: 1 # logical-not-delete value (default is 0)    
	# Custom fill policy interface implementation    
	#meta-object-handler: com.zhengqing.config.   
	#custom SQL injector   
	#sql-injector: com.baomidou.springboot.xxx configuration:      
    #SQL parsing cache, multi-tenant @SqlParser annotation takes effect when enabled
    #sql-parser-cache: true
  configuration:
    # hump conversion Similar mapping from database column names to Java property hump naming  
    map-underscore-to-camel-case: true
    # Whether to enable caching
    cache-enable: false
    # If the query contains a column with a null value, MyBatis will not map this field when mapping        
	#call-setters-on-nulls: true  
    # 打印sql
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

[Solved] yii Frame Error: Warning!symlink() has been disabled for security reasons

Error Messages:

A symlink for "/www/wwwroot/www.atepaoutdoors.com/lib/web/mage/requirejs/mixins.js" can't be created and placed to "/www/wwwroot/www.atepaoutdoors.com/pub/static/frontend/Zemez/theme115/en_US/mage/requirejs/mixins.js". Warning!symlink() has been disabled for security reasons

When deploying the PHP project to the PHP environment on the new server, an error occurs: scandir() symlink() has been disabled for security reasons.

 

How to Solve:

In this case, just go to the PHP installation directory, find php.ini, ctrl+F and search for “disable_functions”, and find the following property configuration.

disable_functions = scandir,passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pls. restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen

Delete scandir and symlink from “disable_functions”, save the php.ini file, restart the service, and refresh the page. This will solve the error problem.