DrKLO/Telegram · error · FlacDecoderException
Failed to initialize decoder
Error message
Failed to initialize decoder
What it means
After the FLAC libraries load, FlacDecoderJni calls the native flacInit(); if it returns 0 the constructor throws FlacDecoderException('Failed to initialize decoder'), indicating the native FLAC decoder context could not be created despite the libraries being available.
Source
Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java:60
}
}
private static final int TEMP_BUFFER_SIZE = 8192; // The same buffer size as libflac.
private final long nativeDecoderContext;
@Nullable private ByteBuffer byteBufferData;
@Nullable private ExtractorInput extractorInput;
@Nullable private byte[] tempBuffer;
private boolean endOfExtractorInput;
public FlacDecoderJni() throws FlacDecoderException {
if (!FlacLibrary.isAvailable()) {
throw new FlacDecoderException("Failed to load decoder native libraries.");
}
nativeDecoderContext = flacInit();
if (nativeDecoderContext == 0) {
throw new FlacDecoderException("Failed to initialize decoder");
}
}
/**
* Sets the data to be parsed.
*
* @param byteBufferData Source {@link ByteBuffer}.
*/
public void setData(ByteBuffer byteBufferData) {
this.byteBufferData = byteBufferData;
this.extractorInput = null;
}
/**
* Sets the data to be parsed.
*
* @param extractorInput Source {@link ExtractorInput}.
*/View on GitHub (pinned to 45ab8f4308)
Solutions
- Rebuild/repackage the FLAC extension native libraries for the correct ABI and library version.
- Fall back to the platform MediaCodec FLAC decoder when FlacDecoderJni construction fails.
- Check for native memory limits / low-memory conditions on the device.
Example fix
// before
try { jni = new FlacDecoderJni(); }
catch (FlacDecoderException e) { /* unhandled crash */ }
// after
try { jni = new FlacDecoderJni(); }
catch (FlacDecoderException e) { usePlatformFlacDecoder(); } Defensive patterns
Strategy: try-catch
Validate before calling
// n/a: failure is internal to native init; no caller-side precondition to check beyond lib availability // ensure FlacLibrary.isAvailable() first (see error 75)
Try / catch
try { new FlacDecoderJni(); }
catch (FlacDecoderException e) { /* rebuild libs or fall back to platform FLAC */ } Prevention
- Use a correctly built FLAC native library matching the device ABI.
- Implement a platform FLAC decoder fallback.
- Watch for low-memory conditions during native init.
When it happens
Trigger: flacInit() returns 0 — typically an internal native allocation/init failure, or a build/version problem in the FLAC JNI library, rather than a data problem (no stream data has been supplied yet at construction time).
Common situations: A broken or ABI-mismatched FLAC native library that loads but fails to allocate its decoder context; memory pressure during native init; a custom/patched FLAC build with an init bug.
Related errors
- Initialization failed.
- Failed to load decoder native libraries.
- Failed to load decoder native libraries.
- Failed to load decoder native libraries
- Initialization data must be of length 1
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/40cc8d3ffe112ad4.
Report an issue: GitHub.