# Dev Notes

## DevTools error message

There's an error message thrown when devtools is opened:

```
2020-09-11 22:00:31.083 te[20533:205250] NSWindow warning: adding an unknown subview: <WKInspectorWKWebView: 0xbd573f0>. Break on NSLog to debug.
2020-09-11 22:00:31.085 te[20533:205250] Call stack:
(
        0   AppKit                              0x00007fff2790f9fd -[NSThemeFrame addSubview:] + 112
        1   AppKit                              0x00007fff2790f73b -[NSView addSubview:positioned:relativeTo:] + 203
        2   AppKit                              0x00007fff2790f5ee -[NSThemeFrame addSubview:positioned:relativeTo:] + 46
        3   WebKit                              0x00007fff3f10b6d3 _ZN6WebKit17WebInspectorProxy14platformAttachEv + 393
        4   WebKit                              0x00007fff3f52a58a _ZN6WebKit17WebInspectorProxy4openEv + 84
        5   WebKit                              0x00007fff3f6af6af _ZN6WebKit17WebInspectorProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 259
        6   WebKit                              0x00007fff3f1583d9 _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 125
        7   WebKit                              0x00007fff3f49d71e _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 28
        8   WebKit                              0x00007fff3f13929e _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 698
        9   WebKit                              0x00007fff3f138b09 _ZN3IPC10Connection24dispatchIncomingMessagesEv + 477
        10  JavaScriptCore                      0x00007fff3bbf789d _ZN3WTF7RunLoop11performWorkEv + 573
        11  JavaScriptCore                      0x00007fff3bbf834a _ZN3WTF7RunLoop11performWorkEPv + 26
        12  CoreFoundation                      0x00007fff24ed34bc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        13  CoreFoundation                      0x00007fff24ed3424 __CFRunLoopDoSource0 + 180
        14  CoreFoundation                      0x00007fff24ed319f __CFRunLoopDoSources0 + 248
        15  CoreFoundation                      0x00007fff24ed1bd1 __CFRunLoopRun + 890
        16  CoreFoundation                      0x00007fff24ed116e CFRunLoopRunSpecific + 563
        17  HIToolbox                           0x00007fff2dbc72e0 RunCurrentEventLoopInMode + 292
        18  HIToolbox                           0x00007fff2dbc70dc ReceiveNextEventCommon + 709
        19  HIToolbox                           0x00007fff2dbc6dff _BlockUntilNextEventMatchingListInModeWithFilter + 64
        20  AppKit                              0x00007fff278e6809 _DPSNextEvent + 879
        21  AppKit                              0x00007fff278e5035 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
        22  AppKit                              0x00007fff278d7628 -[NSApplication run] + 586
        23  te                                  0x000000000421dee8 Run + 1496
        24  te                                  0x000000000406a710 runtime.asmcgocall + 112
)
```

Found this related info: https://bugs.chromium.org/p/chromium/issues/detail?id=605219

```
NSWindow has never supported clients adding subviews to anything other than the contentView. Some applications would add subviews to the contentView.superview (also known as the border view of the window). NSWindow will now log when it detects this scenario: "NSWindow warning: adding an unknown subview:". Applications doing this will need to fix this problem, as it prevents new features on 10.10 from working properly. See titlebarAccessoryViewControllers for official API.

NSWindow now has the ability to add officially known subviews to the titlebar/toolbar area. The views are to be wrapped with a new NSViewController subclass called NSTitlebarAccessoryViewController and added to the window with the "titlebarAccessoryViewControllers" API. There are a set of methods to add and insert the titlebarAccessoryViewControllers, such as addTitlebarAccessoryViewController: and removeTitlebarAccessoryViewControllerAtIndex:. However, one can also utilize "removeFromParentViewController" to easily remove a given child view controller. NSTitlebarAccessoryViewController has a property to tell NSWindow where to place the view (layoutAttribute) and a property to determine how it behaves in full screen (fullScreenMinHeight). The NSToolbar fullScreenAccessoryView API is now deprecated, and clients should utilize this new API.
```

It doesn't appear to cause an issue, but needs resolving.

## Startup timing issue

It seems that even though the runtime is loaded, the CSS + JS after it aren't processed.
Pasting this part in devtools works:
```
window.wails._.InjectCSS("html{text-align:center;}#input{margin:3rem;}#logo{width:50%;height:50%;margin:auto;display:block;background-position:center;background-size:cover;background-image:url(\"data:image/png;base64,[encoded data, 113380 characters]\");}");// Get input + focus
var nameElement = document.getElementById("name");
nameElement.focus();
```

## FIX NEEDED

We currently expect the text `</body>` to appear in the html.
We should find the location of this text using case insensitive regex.