Skip to content

Commit

Permalink
Desktop: Trying to fix white screen issue
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Jun 6, 2023
1 parent 3792a5f commit 8b578c5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
38 changes: 25 additions & 13 deletions packages/app-desktop/app.reducer.ts
Expand Up @@ -4,6 +4,9 @@ import { defaultState, State } from '@joplin/lib/reducer';
import iterateItems from './gui/ResizableLayout/utils/iterateItems';
import { LayoutItem } from './gui/ResizableLayout/utils/types';
import validateLayout from './gui/ResizableLayout/utils/validateLayout';
import Logger from '@joplin/lib/Logger';

const logger = Logger.create('app.reducer');

export interface AppStateRoute {
type: string;
Expand Down Expand Up @@ -171,22 +174,31 @@ export default function(state: AppState, action: any) {
case 'MAIN_LAYOUT_SET_ITEM_PROP':

{
let newLayout = produce(state.mainLayout, (draftLayout: LayoutItem) => {
iterateItems(draftLayout, (_itemIndex: number, item: LayoutItem, _parent: LayoutItem) => {
if (item.key === action.itemKey) {
(item as any)[action.propName] = action.propValue;
return false;
}
return true;
if (!state.mainLayout) {
logger.warn('MAIN_LAYOUT_SET_ITEM_PROP: Trying to set an item prop on the layout, but layout is empty: ', JSON.stringify(action));
} else {
let newLayout = produce(state.mainLayout, (draftLayout: LayoutItem) => {
iterateItems(draftLayout, (_itemIndex: number, item: LayoutItem, _parent: LayoutItem) => {
if (!item) {
logger.warn('MAIN_LAYOUT_SET_ITEM_PROP: Found an empty item in layout: ', JSON.stringify(state.mainLayout));
} else {
if (item.key === action.itemKey) {
(item as any)[action.propName] = action.propValue;
return false;
}
}

return true;
});
});
});

if (newLayout !== state.mainLayout) newLayout = validateLayout(newLayout);
if (newLayout !== state.mainLayout) newLayout = validateLayout(newLayout);

newState = {
...state,
mainLayout: newLayout,
};
newState = {
...state,
mainLayout: newLayout,
};
}
}

break;
Expand Down
10 changes: 1 addition & 9 deletions packages/app-desktop/app.ts
Expand Up @@ -557,15 +557,7 @@ class Application extends BaseApplication {

bridge().addEventListener('nativeThemeUpdated', this.bridge_nativeThemeUpdated);

// We need to delay plugin initialisation until the main screen is
// ready. Otherwise plugins might try to modify the application layout,
// which will cause an error related to an empty layout item. This in
// turns will cause the screen to go white on startup.
//
// https://discourse.joplinapp.org/t/upgrade-produces-blank-window/31138/8
eventManager.on('mainScreenReady', () => {
void this.initPluginService();
});
await this.initPluginService();

this.setupContextMenu();

Expand Down
2 changes: 0 additions & 2 deletions packages/app-desktop/gui/MainScreen/MainScreen.tsx
Expand Up @@ -46,7 +46,6 @@ import PromptDialog from '../PromptDialog';
import NotePropertiesDialog from '../NotePropertiesDialog';
const PluginManager = require('@joplin/lib/services/PluginManager');
const ipcRenderer = require('electron').ipcRenderer;
import eventManager from '@joplin/lib/eventManager';

interface LayerModalState {
visible: boolean;
Expand Down Expand Up @@ -392,7 +391,6 @@ class MainScreenComponent extends React.Component<Props, State> {

public componentDidMount() {
window.addEventListener('keydown', this.layoutModeListenerKeyDown);
eventManager.emit('mainScreenReady');
}

public componentWillUnmount() {
Expand Down

1 comment on commit 8b578c5

@taw00
Copy link
Contributor

@taw00 taw00 commented on 8b578c5 Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not fixed: Joplin 2.11.11

Scenario (this time):

  • at a cafe
  • wifi is searching, but no network associated yet
  • Joplin ... hangs.
  • SUB-BUG: I can't exit Joplin in this state unless I kill -9 the process. That ALSO needs to be addressed IMHO.

Screenshot from 2023-06-29 11-51-07

I would do debugging and crap but I have to get work done. Maybe next time.

Please sign in to comment.