{"record":{"id":"3188e757d98d56b6","repo":"sgl-project/sglang","slug":"this-browser-cannot-encode-h-264-mp4","errorCode":null,"errorMessage":"This browser cannot encode H.264 MP4","messagePattern":"This browser cannot encode H\\.264 MP4","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/realtime_webui/app.js","lineNumber":669,"sourceCode":"    { codec: \"avc1.4d4028\", width, height, bitrate, framerate: fps },\n    { codec: \"avc1.42e028\", width, height, bitrate, framerate: fps },\n  ];\n  let supported = null;\n  for (const config of configs) {\n    const candidate = {\n      ...config,\n      avc: { format: \"avc\" },\n      bitrateMode: \"variable\",\n      hardwareAcceleration: \"prefer-hardware\",\n      latencyMode: \"realtime\",\n    };\n    const result = await VideoEncoder.isConfigSupported(candidate);\n    if (result.supported) {\n      supported = result.config;\n      break;\n    }\n  }\n  if (!supported) throw new Error(\"This browser cannot encode H.264 MP4\");\n  recordingEncoderConfig = supported;\n  recordingEncoder = new VideoEncoder({\n    output: (chunk, metadata) => recordEncodedChunk(chunk, metadata),\n    error: (error) => {\n      recordingActive = false;\n      addHistory(error.message || \"recording encoder failed\");\n      updateRecordButton();\n    },\n  });\n  recordingEncoder.configure(supported);\n}\n\nfunction recordEncodedChunk(chunk, metadata) {\n  if (metadata?.decoderConfig?.description) {\n    recordingEncoderConfig.description = metadata.decoderConfig.description;\n  }\n  const data = new Uint8Array(chunk.byteLength);\n  chunk.copyTo(data);","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/realtime_webui/app.js#L651-L687","documentation":"Thrown by ngram_corpus Param::parse while parsing a spec-configuration segment. Each segment must split on '|' into exactly two parts: a positional range and a config value. Seeing part's size != 2 means the segment is malformed — missing the '|' separator or containing extra ones.","triggerScenarios":"resetBatchReturnTokenNum is called with a config string whose pipe-separated segments don't each contain exactly one '|', e.g. \"2-4\" (no config part), \"2-4|8|9\" (extra part), or an empty/trailing segment like \"2-4|8|\".","commonSituations":"Typos in the speculative n-gram config string passed via CLI/server args, config strings assembled programmatically with a missing or duplicated '|' delimiter, or trailing separators after string joins.","solutions":["Fix the config string so every segment is exactly 'L-R|value', e.g. '2-4|8'","Print/inspect the segments the parser sees (the code already dumps each 'part' to stderr) to find the malformed one","Validate the config format in Python before passing it into the C++ API"],"exampleFix":"# before\nparam.resetBatchReturnTokenNum(\"2-4 5-8|3\")\n\n# after\nparam.resetBatchReturnTokenNum(\"2-4|3 5-8|3\")","handlingStrategy":"validation","validationCode":"import re\nSEG = re.compile(r\"^\\d+-\\d+\\|\\d+$\")\nassert all(SEG.match(s) for s in cfg.split()), f\"bad ngram config segment in {cfg!r}\"","typeGuard":"def is_valid_ngram_config(cfg: str) -> bool:\n    segs = cfg.split()\n    return bool(segs) and all(re.fullmatch(r\"\\d+-\\d+\\|\\d+\", s) for s in segs)","tryCatchPattern":"try:\n    param.resetBatchReturnTokenNum(cfg)\nexcept RuntimeError as e:\n    if \"invalid config\" in str(e):\n        raise ValueError(f\"ngram config malformed: {cfg!r} (expected 'L-R|value' segments)\") from e\n    raise","preventionTips":["Build config strings from structured (L, R, value) tuples via a single formatter f\"{L}-{R}|{v}\"","Strip whitespace and trailing separators before passing to C++","Unit-test the config parser against valid and invalid samples"],"tags":["ngram","config","parsing","speculative-decoding"],"backgroundTag":"config-string-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}