{"record":{"id":"3b485bd3ace0db6e","repo":"koral--/android-gif-drawable","slug":"speed-factor-is-not-positive","errorCode":null,"errorMessage":"Speed factor is not positive","messagePattern":"Speed factor is not positive","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java","lineNumber":247,"sourceCode":"\t\tif (loopCount < 0 || loopCount > Character.MAX_VALUE) {\n\t\t\tthrow new IllegalArgumentException(\"Loop count of range <0, 65535>\");\n\t\t}\n\t\tsynchronized (this) {\n\t\t\tsetLoopCount(gifInfoPtr, (char) loopCount);\n\t\t}\n\t}\n\n\tsynchronized long getSourceLength() {\n\t\treturn getSourceLength(gifInfoPtr);\n\t}\n\n\tsynchronized int getNativeErrorCode() {\n\t\treturn getNativeErrorCode(gifInfoPtr);\n\t}\n\n\tvoid setSpeedFactor(@FloatRange(from = 0, fromInclusive = false) float factor) {\n\t\tif (factor <= 0f || Float.isNaN(factor)) {\n\t\t\tthrow new IllegalArgumentException(\"Speed factor is not positive\");\n\t\t}\n\t\tif (factor < 1f / Integer.MAX_VALUE) {\n\t\t\tfactor = 1f / Integer.MAX_VALUE;\n\t\t}\n\t\tsynchronized (this) {\n\t\t\tsetSpeedFactor(gifInfoPtr, factor);\n\t\t}\n\t}\n\n\tsynchronized int getDuration() {\n\t\treturn getDuration(gifInfoPtr);\n\t}\n\n\tsynchronized int getCurrentPosition() {\n\t\treturn getCurrentPosition(gifInfoPtr);\n\t}\n\n\tsynchronized int getCurrentFrameIndex() {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java#L229-L265","documentation":"GifInfoHandle.setSpeedFactor requires a strictly positive, non-NaN float. Non-positive or NaN values raise IllegalArgumentException('Speed factor is not positive'). Values below 1/Integer.MAX_VALUE are silently clamped to that minimum instead of throwing.","triggerScenarios":"Calling setSpeedFactor(0), a negative factor, or Float.NaN — often the result of a division whose denominator was 0, or parsing an invalid speed string.","commonSituations":"Computing speed from user settings where 0 means 'paused' (use pause()/stop() instead); uninitialized float fields defaulting to 0f; NaN from unvalidated arithmetic.","solutions":["Validate factor > 0 and !Float.isNaN(factor) before calling setSpeedFactor.","Use the drawable's pause()/stop()/start() APIs for pausing rather than a 0 speed factor.","Guard divisions that produce the factor against zero denominators."],"exampleFix":"// before\ngifDrawable.setSpeedFactor(userSpeed); // may be 0\n// after\nif (userSpeed > 0f && !Float.isNaN(userSpeed)) {\n    gifDrawable.setSpeedFactor(userSpeed);\n} else {\n    gifDrawable.pause();\n}","handlingStrategy":"validation","validationCode":"if (factor > 0f && !Float.isNaN(factor)) { gifInfoHandle.setSpeedFactor(factor); }","typeGuard":"boolean isValidSpeedFactor(float f) { return f > 0f && !Float.isNaN(f); }","tryCatchPattern":"try { gifInfoHandle.setSpeedFactor(factor); } catch (IllegalArgumentException e) { gifDrawable.pause(); }","preventionTips":["Use pause()/stop() for 'zero speed' semantics","Guard speed computations against division by zero","Initialize speed fields with 1.0f, not 0f"],"tags":["android","argument-out-of-range","animation"],"backgroundTag":"invalid-argument-value","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}