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

Getting "TypeError: Cannot read properties of null (reading 'getElementsByTagName')" #197

Open
nfairfield opened this issue Oct 25, 2024 · 1 comment

Comments

@nfairfield
Copy link

Question: Are you using the latest version of flutter_tex package? pub package
Answer:Yes, using repo

I originally had the issue with the latest pub package, but I check that I also get it in the example in the repo. When I run the example app (Chrome web-javascript, flutter and click on the Quiz button, I immediately see the following in the console:

TypeError: Cannot read properties of null (reading 'getElementsByTagName')
assets/packages/flutter_tex/js/katex/contrib/mathtex-script-type.min.js 1:892
assets/packages/flutter_tex/js/katex/contrib/mathtex-script-type.min.js 1:1288
assets/packages/flutter_tex/js/katex/contrib/mathtex-script-type.min.js 1:1303
assets/packages/flutter_tex/js/katex/contrib/mathtex-script-type.min.js 1:226
assets/packages/flutter_tex/js/katex/contrib/mathtex-script-type.min.js 1:298

This seems to be related to a problem where onRenderFinished just is never called, and/or sometimes (feels like some sort of race condition with refreshing the page?) seems to fail with:

TypeError: Cannot read properties of null (reading 'offsetHeight')
assets/packages/flutter_tex/js/flutter_tex.js 182:26 getTeXViewHeight
assets/packages/flutter_tex/js/flutter_tex.js 138:18 renderCompleted
assets/packages/flutter_tex/js/katex/index.html 49:17

Which is turn may be related to a problem where all except the last TeXView on a page don't render properly (just a little horizontal bar), unless I strictly put everything inside a SizedBox... Which is the actual issue I'm trying to track down. (Screenshot shows a GridView of three TeXViews side-by-side, and only the last one is actually rendering: all three should have exactly the same text).

image

Versions:
Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2663184aa7 (6 weeks ago) • 2024-09-11 16:27:48 -0500
Engine • revision 36335019a8
Tools • Dart 3.5.3 • DevTools 2.37.3

Chrome Version 130.0.6723.59 (Official Build) (64-bit)

Windows 11 Version 10.0.22631 Build 22631

@nfairfield
Copy link
Author

Two updates:

  • The last problem, rendering correctly, is fixed after I wrapped the TeXViews in Expanded widgets.
  • I confirmed that changing the rendering engine to mathjax (from the default katex) prevents the TypeErrors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant