瀏覽代碼

Fix segmentation fault and UI state issues (#5, #6)

This commit addresses two critical issues:

**Issue #5: Segmentation fault on second generation job**
- Fixed dangling progress callback pointer causing segfault
- Added sd_set_progress_callback(nullptr, nullptr) to clear callbacks
- Applied fix to text2img, img2img, and controlnet generation functions
- Now properly clears callback before deleting callback data

Changes in src/stable_diffusion_wrapper.cpp:
- Clear progress callback in generateText2Img() at line 154
- Clear progress callback in generateImg2Img() at line 264
- Clear progress callback in generateControlNet() at line 375

**Issue #6: UI state not resetting after job completion**
- Fixed jobInfo display persisting after generation completes
- Changed condition from {jobInfo && ...} to {loading && jobInfo && ...}
- Job status now only displays during active generation
- Generate button is now immediately reusable after completion
- Improved Job ID display to handle both id and request_id fields

Changes in webui pages:
- webui/app/text2img/page.tsx: Conditional jobInfo display (line 350)
- webui/app/img2img/page.tsx: Conditional jobInfo display (line 342)
- webui/app/upscaler/page.tsx: Conditional jobInfo display (line 275)

Note: Issue #7 (queue view image enhancement) was already implemented
in a previous commit and is working correctly.

Fixes #5
Fixes #6
Fszontagh 3 月之前
父節點
當前提交
b19107124d
共有 4 個文件被更改,包括 12 次插入9 次删除
  1. 6 3
      src/stable_diffusion_wrapper.cpp
  2. 2 2
      webui/app/img2img/page.tsx
  3. 2 2
      webui/app/text2img/page.tsx
  4. 2 2
      webui/app/upscaler/page.tsx

+ 6 - 3
src/stable_diffusion_wrapper.cpp

@@ -150,7 +150,8 @@ public:
         // Generate the image
         sd_image_t* sdImages = generate_image(sdContext, &genParams);
 
-        // Clean up progress callback data
+        // Clear and clean up progress callback
+        sd_set_progress_callback(nullptr, nullptr);
         if (callbackData) {
             delete callbackData;
             callbackData = nullptr;
@@ -260,7 +261,8 @@ public:
         // Generate the image
         sd_image_t* sdImages = generate_image(sdContext, &genParams);
 
-        // Clean up progress callback data
+        // Clear and clean up progress callback
+        sd_set_progress_callback(nullptr, nullptr);
         if (callbackData) {
             delete callbackData;
             callbackData = nullptr;
@@ -370,7 +372,8 @@ public:
         // Generate the image
         sd_image_t* sdImages = generate_image(sdContext, &genParams);
 
-        // Clean up progress callback data
+        // Clear and clean up progress callback
+        sd_set_progress_callback(nullptr, nullptr);
         if (callbackData) {
             delete callbackData;
             callbackData = nullptr;

+ 2 - 2
webui/app/img2img/page.tsx

@@ -339,9 +339,9 @@ export default function Img2ImgPage() {
                   </div>
                 )}
 
-                {jobInfo && (
+                {loading && jobInfo && (
                   <div className="rounded-md bg-muted p-3 text-sm">
-                    <p>Job ID: {jobInfo.id}</p>
+                    <p>Job ID: {jobInfo.id || jobInfo.request_id || 'N/A'}</p>
                     <p>Status: {jobInfo.status}</p>
                     {jobInfo.progress !== undefined && (
                       <p>Progress: {Math.round(jobInfo.progress * 100)}%</p>

+ 2 - 2
webui/app/text2img/page.tsx

@@ -347,9 +347,9 @@ export default function Text2ImgPage() {
                   </div>
                 )}
 
-                {jobInfo && (
+                {loading && jobInfo && (
                   <div className="rounded-md bg-muted p-3 text-sm">
-                    <p>Job ID: {jobInfo.id}</p>
+                    <p>Job ID: {jobInfo.id || jobInfo.request_id || 'N/A'}</p>
                     <p>Status: {jobInfo.status}</p>
                     {jobInfo.progress !== undefined && (
                       <p>Progress: {Math.round(jobInfo.progress * 100)}%</p>

+ 2 - 2
webui/app/upscaler/page.tsx

@@ -272,9 +272,9 @@ export default function UpscalerPage() {
                   </div>
                 )}
 
-                {jobInfo && (
+                {loading && jobInfo && (
                   <div className="rounded-md bg-muted p-3 text-sm">
-                    <p>Job ID: {jobInfo.id}</p>
+                    <p>Job ID: {jobInfo.id || jobInfo.request_id || 'N/A'}</p>
                     <p>Status: {jobInfo.status}</p>
                     {jobInfo.progress !== undefined && (
                       <p>Progress: {Math.round(jobInfo.progress * 100)}%</p>