From 6a96de4073e3fba603dc52c69e2d19decc60badd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Nov 2025 12:59:22 +0000 Subject: [PATCH] Fix: Resolve BrowserView attachment error on password unlock Fixes JavaScript error "given browserview is not attached to the window" that occurred when unlocking the screen after boot with password protection. Changes to unlockScreen() function: - Add try-catch around hidden view restoration to prevent crashes - Ensure view is attached with addBrowserView() before setTopBrowserView() - Add fallback to regular views if hidden view restoration fails - Validate currentIndex is within bounds before using it - Check views.length>0 before attempting to attach views This ensures safe view restoration in all unlock scenarios, particularly when unlocking immediately after boot with password protection enabled. --- install_kiosk_0.9.5-10.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/install_kiosk_0.9.5-10.sh b/install_kiosk_0.9.5-10.sh index 63acaa2..e2852ab 100644 --- a/install_kiosk_0.9.5-10.sh +++ b/install_kiosk_0.9.5-10.sh @@ -4040,12 +4040,26 @@ function unlockScreen(){ } // Restore current view using proper method + // For boot unlock, always use attachView for regular views (safe path) if(showingHidden&&hiddenViews[currentHiddenIndex]){ - const[w,h]=mainWindow.getContentSize(); - mainWindow.setTopBrowserView(hiddenViews[currentHiddenIndex]); - hiddenViews[currentHiddenIndex].setBounds({x:0,y:0,width:w,height:h}); - }else if(views[currentIndex]){ - attachView(currentIndex); + try{ + const[w,h]=mainWindow.getContentSize(); + // Ensure view is added to window before setting as top + mainWindow.addBrowserView(hiddenViews[currentHiddenIndex]); + mainWindow.setTopBrowserView(hiddenViews[currentHiddenIndex]); + hiddenViews[currentHiddenIndex].setBounds({x:0,y:0,width:w,height:h}); + }catch(e){ + console.error('[LOCKOUT] Error restoring hidden view:',e); + // Fallback to regular views + if(views.length>0){ + showingHidden=false; + attachView(0); + } + } + }else if(views.length>0){ + // Use valid index or default to 0 + const idx=(currentIndex>=0&¤tIndex