Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrysalis needs to handle cases when loading keymaps from json that don't have the right # of layers. #1346

Open
oscar-schwarz opened this issue Aug 15, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@oscar-schwarz
Copy link

oscar-schwarz commented Aug 15, 2024

Describe the bug
I exported a layout from the web version of the app and tried to import it again.
On selection of the file the site goes white and in the console it says
Error: Minified React error #310; visit https://reactjs.org/docs/error-decoder.html?invariant=310 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Obviously that error is not very useful so I ran the app on my local machine to get a nicer react error:

Warning: React has detected a change in the order of Hooks called by Overview. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks

   Previous render            Next render
   ------------------------------------------------------
1. useContext                 useContext
2. useState                   useState
3. useRef                     useRef
4. useEffect                  useEffect
5. useRef                     useRef
6. useEffect                  useEffect
7. useRef                     useRef
8. useEffect                  useEffect
9. useState                   useState
10. useEffect                 useEffect
11. useState                  useState
12. useState                  useState
13. useState                  useState
14. useState                  useState
15. useState                  useState
16. useState                  useState
17. useState                  useState
18. useState                  useState
19. useState                  useState
20. undefined                 useState
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    at Overview (http://localhost:8080/main.bundle.js:81184:40)
    at div
    at http://localhost:8080/main.bundle.js:828:66
    at Box (http://localhost:8080/main.bundle.js:60536:72)
    at Editor (http://localhost:8080/main.bundle.js:84017:40)
    at div
    at FocusHandlerImpl (http://localhost:8080/main.bundle.js:2836:5)
    at FocusHandler (http://localhost:8080/main.bundle.js:2807:19)
    at RouterImpl (http://localhost:8080/main.bundle.js:2712:5)
    at Location (http://localhost:8080/main.bundle.js:2541:23)
   ...

Uncaught Error: Rendered more hooks than during the previous render.
    at updateWorkInProgressHook (react-dom.development.js:16507:1)
    at updateReducer (react-dom.development.js:16568:1)
    at updateState (react-dom.development.js:17004:1)
    at Object.useState (react-dom.development.js:17915:1)
    at useState (react.development.js:1622:1)
    at HamburgerMenu (Overview.js:79:45)
    at Overview.js:173:12
    at Array.map (<anonymous>)
    at Overview (Overview.js:129:29)
    at renderWithHooks (react-dom.development.js:16305:1)
   ...

The above error occurred in the <Overview> component:

    at Overview (http://localhost:8080/main.bundle.js:81184:40)
    at div
    at http://localhost:8080/main.bundle.js:828:66
    at Box (http://localhost:8080/main.bundle.js:60536:72)
    at Editor (http://localhost:8080/main.bundle.js:84017:40)
    at div
    at FocusHandlerImpl (http://localhost:8080/main.bundle.js:2836:5)
    at FocusHandler (http://localhost:8080/main.bundle.js:2807:19)
    at RouterImpl (http://localhost:8080/main.bundle.js:2712:5)
    at Location (http://localhost:8080/main.bundle.js:2541:23)
    at Router
    at main
    ...



Uncaught Error: Rendered more hooks than during the previous render.
    at updateWorkInProgressHook (react-dom.development.js:16507:1)
    at updateReducer (react-dom.development.js:16568:1)
    at updateState (react-dom.development.js:17004:1)
    at Object.useState (react-dom.development.js:17915:1)
    at useState (react.development.js:1622:1)
    at HamburgerMenu (Overview.js:79:45)
    at Overview.js:173:12
    at Array.map (<anonymous>)
    at Overview (Overview.js:129:29)
    at renderWithHooks (react-dom.development.js:16305:1)
    ...
    React will try to recreate this component tree from scratch using the error boundary you provided, LocationProvider.

The above error occurred in the <LocationProvider> component:

    at LocationProvider (http://localhost:8080/main.bundle.js:2561:5)
    at div
    at http://localhost:8080/main.bundle.js:828:66
    at Box (http://localhost:8080/main.bundle.js:60536:72)
    at div
    at DndProvider (http://localhost:8080/main.bundle.js:196535:11)
    at ThemeProvider (http://localhost:8080/main.bundle.js:57946:5)
    at ThemeProvider (http://localhost:8080/main.bundle.js:59028:5)
    at ThemeProvider (http://localhost:8080/main.bundle.js:55115:14)
    at StyledEngineProvider (http://localhost:8080/main.bundle.js:58129:5)
    at Suspense
    at App (http://localhost:8080/main.bundle.js:76119:40)
    at GlobalContextProvider (http://localhost:8080/main.bundle.js:76747:49)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.


Uncaught Error: Rendered more hooks than during the previous render.
    at updateWorkInProgressHook (react-dom.development.js:16507:1)
    at updateReducer (react-dom.development.js:16568:1)
    at updateState (react-dom.development.js:17004:1)
    at Object.useState (react-dom.development.js:17915:1)
    at useState (react.development.js:1622:1)
    at HamburgerMenu (Overview.js:79:45)
    at Overview.js:173:12
    at Array.map (<anonymous>)
    at Overview (Overview.js:129:29)
    at renderWithHooks (react-dom.development.js:16305:1)

I haven't worked with react yet, this doesn't look very useful to me but is most likely more useful than the other error.

To Reproduce
Steps to reproduce the behavior:

  1. Connect a Keyboardio Atreus with the latest firmware
  2. Click on "Backup and Restore layouts"
  3. Click on "Restore from File..." and select the JSON from above
  4. Now the page should be white and an error should be displayed in the console

Expected behavior
No error occurs and layout gets imported correctly.

Screenshots
The error on https://chrysalis.keyboard.io
image

Interestingly the layout seems to load and the error occurs afterwards

Heres is the debug file from the "Report a problem" page: debug.txt

@oscar-schwarz oscar-schwarz added the bug Something isn't working label Aug 15, 2024
@obra
Copy link
Member

obra commented Aug 15, 2024 via email

@oscar-schwarz
Copy link
Author

I see. The only reason I tried the desktop version was because on the web version the import fails too. I will edit this report later so it resembles the web bug.

@obra
Copy link
Member

obra commented Aug 15, 2024

Sure thing. That should absolutely work. The debug log from the web import attempt would be very helpful.

Best,
Jesse

@oscar-schwarz oscar-schwarz changed the title Error on installing imported JSON layout Error on importing JSON layout Aug 16, 2024
@oscar-schwarz
Copy link
Author

I updated the issue so that it represents the web bug.

@oscar-schwarz
Copy link
Author

I managed to repair my layout json by comparing it to a similar working file export. Heres the diff. It seems the structure of the last layer was messed up. But that it the applications fault. I havent messed with that file. But I have no idea how to reproduce that wrong export behaviour.

@obra
Copy link
Member

obra commented Aug 16, 2024 via email

@oscar-schwarz
Copy link
Author

Sadly not. But I know it was a version without mouse and macro support and layer 8 and 9 were greyed out in Chrysalis.

@obra obra changed the title Error on importing JSON layout Chrysalis needs to handle cases when loading keymaps from json that don't have the right # of layers. Aug 16, 2024
@obra
Copy link
Member

obra commented Aug 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants