Shahxad-Akram / flutter_tex

A Flutter Package to render Mathematics, Physics and Chemistry Equations based on LaTeX
https://pub.dartlang.org/packages/flutter_tex
Other
281 stars 136 forks source link

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

Open nfairfield opened 4 weeks ago

nfairfield commented 4 weeks ago

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 commented 4 weeks ago

Two updates: