Hi @Physikerwelt,
I'm hoping you can help me with the Math extension again. I am looking at moving my wiki from MW 1.26 to MW 1.28.
In MW 1.26 you previously helped me in T119187 to get the Math extension working which I greatly appreciated. For reasons I do not fathom eventually the Math extension just stopped working around June 2016 (without I think any intervention on the server). Short on time I used SimpleMathJax for quite a while.
I'm now trying to get MW 1.28 working nicely through a bunch of Docker images and trying to reinstate the Math extension.
If I specify the settings as shown below:
# Math extension # - this was removed June 2016 as not functioning correctly and repalced with SimpleMathJax # - reinstated for testing in MW 1.28 require_once "$IP/extensions/Math/Math.php"; # wfLoadExtension( 'Math' ); // Set Mathoid as default rendering option; $wgMathValidModes[] = 'mathml'; $wgDefaultUserOptions['math'] = 'mathml'; $wgMathMathMLUrl = 'http://mediawiki-mathoid-1:10044/'; # IP of Mathoid server # $wgMathFullRestbaseURL = 'http://mediawiki-mathoid-1:10044/'; # IP of Mathoid server $wgMathFullRestbaseURL= 'https://api.formulasearchengine.com/';
Then going to Special:MathStatus gives me 'succeeded' for all tests.
However on a page which might have 20 or 30 formulas, I find some do not render correctly and show instead:
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle \Omega}
I can't see anything much that I can do about this. It's quite repeatable and I'm not sure how to diagnose further.
So:
- Problem 1: Using the default Math settings doesn't provide consistent performance. No particular idea of what diagnostics to do to explore this further.
I thought. "Why don't I set up a local mathoid install to see if I can get better performance?'. The commented out $wgMathFullRestbaseURL points to a local docker container. This runs in a separate container to the mediawiki instance, however to test I carry out (within the mediawiki container) a command like this:
root@6705d8cb6e2e:/var/www/html/mediawiki# curl -d 'q=E=mc^2' mediawiki-mathoid-1:10044 curl: (7) Failed to connect to mediawiki-mathoid-1 port 10044: Connection refused root@6705d8cb6e2e:/var/www/html/mediawiki# curl -d 'q=E=mc^2' mediawiki-mathoid-1:10044 curl: (7) Failed to connect to mediawiki-mathoid-1 port 10044: Connection refused root@6705d8cb6e2e:/var/www/html/mediawiki# curl -d 'q=E=mc^2' mediawiki-mathoid-1:10044 {"mml":"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\">\n <semantics>\n <mrow>\n <mi>E</mi>\n <mo>=</mo>\n <mi>m</mi>\n <msup>\n <mi>c</mi>\n <mn>2</mn>\n </msup>\n </mrow>\n <annotation encoding=\"application/x-tex\">E=mc^2</annotation>\n </semantics>\n</math>","svg":"<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"9.025ex\" height=\"2.676ex\" style=\"vertical-align: -0.338ex;\" viewBox=\"0 -1006.6 3885.6 1152.1\" xmlns=\"http://www.w3.org/2000/svg\">\n<defs>\n<path stroke-width=\"10\" id=\"E1-MJMATHI-45\" d=\"M492 213Q472 213 472 226Q472 230 477 250T482 285Q482 316 461 323T364 330H312Q311 328 277 192T243 52Q243 48 254 48T334 46Q428 46 458 48T518 61Q567 77 599 117T670 248Q680 270 683 272Q690 274 698 274Q718 274 718 261Q613 7 608 2Q605 0 322 0H133Q31 0 31 11Q31 13 34 25Q38 41 42 43T65 46Q92 46 125 49Q139 52 144 61Q146 66 215 342T285 622Q285 629 281 629Q273 632 228 634H197Q191 640 191 642T193 659Q197 676 203 680H757Q764 676 764 669Q764 664 751 557T737 447Q735 440 717 440H705Q698 445 698 453L701 476Q704 500 704 528Q704 558 697 578T678 609T643 625T596 632T532 634H485Q397 633 392 631Q388 629 386 622Q385 619 355 499T324 377Q347 376 372 376H398Q464 376 489 391T534 472Q538 488 540 490T557 493Q562 493 565 493T570 492T572 491T574 487T577 483L544 351Q511 218 508 216Q505 213 492 213Z\"></path>\n<path stroke-width=\"10\" id=\"E1-MJMAIN-3D\" d=\"M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z\"></path>\n<path stroke-width=\"10\" id=\"E1-MJMATHI-6D\" d=\"M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z\"></path>\n<path stroke-width=\"10\" id=\"E1-MJMATHI-63\" d=\"M34 159Q34 268 120 355T306 442Q362 442 394 418T427 355Q427 326 408 306T360 285Q341 285 330 295T319 325T330 359T352 380T366 386H367Q367 388 361 392T340 400T306 404Q276 404 249 390Q228 381 206 359Q162 315 142 235T121 119Q121 73 147 50Q169 26 205 26H209Q321 26 394 111Q403 121 406 121Q410 121 419 112T429 98T420 83T391 55T346 25T282 0T202 -11Q127 -11 81 37T34 159Z\"></path>\n<path stroke-width=\"10\" id=\"E1-MJMAIN-32\" d=\"M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z\"></path>\n</defs>\n<g stroke=\"currentColor\" fill=\"currentColor\" stroke-width=\"0\" transform=\"matrix(1 0 0 -1 0 0)\">\n <use xlink:href=\"#E1-MJMATHI-45\" x=\"0\" y=\"0\"></use>\n <use xlink:href=\"#E1-MJMAIN-3D\" x=\"1046\" y=\"0\"></use>\n <use xlink:href=\"#E1-MJMATHI-6D\" x=\"2107\" y=\"0\"></use>\n<g transform=\"translate(2990,0)\">\n <use xlink:href=\"#E1-MJMATHI-63\" x=\"0\" y=\"0\"></use>\n <use transform=\"scale(0.707)\" xlink:href=\"#E1-MJMAIN-32\" x=\"619\" y=\"583\"></use>\n</g>\n</g>\n</svg>","mathoidStyle":"vertical-align: -0.338ex; width:9.025ex; height:2.676ex;","success":true,"log":"success"}root@6705d8cb6e2e:/var/www/html/mediawiki#
This works - but sporadically. Sometimes I get a refused connection. Sometimes the curl command hangs and I get a 'Connection reset by peer'. I think this is more likely a problem with mathoid then a container connectivity issue.
My config.yaml is straightforward. I think only a port change. It would be great if there was some guidance on stats and logging if not part of a Wikimedia cluster (what should be changed and what dependencies are required). I don't know how to redirect logs to a local file, which would be quite useful.
# Number of worker processes to spawn. # Set to 0 to run everything in a single process without clustering. # Use 'ncpu' to run as many workers as there are CPU units num_workers: ncpu # Log error messages and gracefully restart a worker if v8 reports that it # uses more heap (note: not RSS) than this many mb. worker_heap_limit_mb: 500 # Logger info logging: level: warn streams: # Use gelf-stream -> logstash - type: gelf host: logstash1003.eqiad.wmnet port: 12201 # Statsd metrics reporter metrics: type: statsd host: statsd.eqiad.wmnet port: 8125 services: - name: mathoid # a relative path or the name of an npm package, if different from name module: ./app.js # optionally, a version constraint of the npm package # version: ^0.4.0 # per-service config conf: port: 10044 # interface: localhost # uncomment to only listen on localhost # more per-service config settings svg: true img: true texvcinfo: true speech: true speech_on: false no_check: true
The Dockerfile for this container (which I thought might be useful on the mathoid repo) is the following:
FROM buildpack-deps:jessie-curl # from: https://www.mediawiki.org/wiki/Mathoid # and: https://github.com/wikimedia/mathoid ################################################################### #********************* Environment Variables *********************# ################################################################### # terminal setup for nano ENV TERM xterm ################################################################### #************************* Install Mathoid ***********************# ################################################################### WORKDIR /root # Install Node 4.x RUN sh -c "curl -sL https://deb.nodesource.com/setup_4.x | bash -" # Dependencies RUN apt-get install -y git nodejs librsvg2-dev build-essential nano # Version check RUN npm -v RUN node -v # Modules after mathoid required for testing RUN npm install mathoid mocha extend rewire mocha-jshint COPY import/docker-entrypoint.sh /entrypoint.sh COPY import/config.yaml /root/node_modules/mathoid/config.yaml # Port for accessing Mathoid API EXPOSE 10044 ENTRYPOINT ["/entrypoint.sh"] # Mathoid installed to this location WORKDIR /root/node_modules/mathoid CMD ["nodejs", "server.js"] # try: # - curl -d 'q=E=mc^2' localhost:10044
When I change the LocalSettings.php configuration file to use the local mathoid server:
$wgMathMathMLUrl = 'http://mediawiki-mathoid-1:10044/'; # IP of Mathoid server $wgMathFullRestbaseURL = 'http://mediawiki-mathoid-1:10044/'; # IP of Mathoid server # $wgMathFullRestbaseURL= 'https://api.formulasearchengine.com/';
then none of my formulas render when I force a page refresh. All give the same error:
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "http://mediawiki-mathoid-1:10044/v1/":): {\displaystyle R_{arc}=\frac{28707L}{I^{{1.4}}}}
Now when I go to Special:MathStatus I see the following (after quite a lengthy delay and a couple of clicks on the page name):
Internal error [5a8d27c5c95bf895f55ae13e] /mediawiki/index.php/Special:MathStatus MWException from line 104 of /var/www/html/mediawiki/extensions/Math/MathRestbaseInterface.php: TeX input is invalid. Backtrace: #0 /var/www/html/mediawiki/extensions/Math/MathRestbaseInterface.php(395): MathRestbaseInterface->calculateHash() #1 /var/www/html/mediawiki/extensions/Math/MathRestbaseInterface.php(95): MathRestbaseInterface->getContentRequest(string) #2 /var/www/html/mediawiki/extensions/Math/MathRestbaseInterface.php(224): MathRestbaseInterface->getContent(string) #3 /var/www/html/mediawiki/extensions/Math/MathRenderer.php(657): MathRestbaseInterface->getSvg() #4 /var/www/html/mediawiki/extensions/Math/MathMathML.php(357): MathRenderer->getSvg() #5 /var/www/html/mediawiki/extensions/Math/MathMathML.php(398): MathMathML->correctSvgStyle(NULL) #6 /var/www/html/mediawiki/extensions/Math/MathMathML.php(466): MathMathML->getFallbackImage() #7 /var/www/html/mediawiki/extensions/Math/SpecialMathStatus.php(70): MathMathML->getHtmlOutput() #8 /var/www/html/mediawiki/extensions/Math/SpecialMathStatus.php(52): SpecialMathStatus->testSpecialCaseText() #9 /var/www/html/mediawiki/extensions/Math/SpecialMathStatus.php(42): SpecialMathStatus->runMathMLTest(string) #10 /var/www/html/mediawiki/includes/specialpage/SpecialPage.php(522): SpecialMathStatus->execute(NULL) #11 /var/www/html/mediawiki/includes/specialpage/SpecialPageFactory.php(576): SpecialPage->run(NULL) #12 /var/www/html/mediawiki/includes/MediaWiki.php(283): SpecialPageFactory::executePath(Title, RequestContext) #13 /var/www/html/mediawiki/includes/MediaWiki.php(851): MediaWiki->performRequest() #14 /var/www/html/mediawiki/includes/MediaWiki.php(512): MediaWiki->main() #15 /var/www/html/mediawiki/index.php(43): MediaWiki->run() #16 {main}
So:
- Problem 2: Even with a mathoid service running, integration with Mediawiki seems problematic and seems to cause failure of the MathStatus page.
One thing is I am a little unsure if wgMathFullRestbaseURL should include the port number for a custom instance. Could you confirm? I have tried both ways without either causing the MathStatus page to render correctly.
Any and all help appreciated :-)