error library

LMSInitialize failed: find the first failing call

LMSInitialize failed

The course could not open its SCORM session. Either it never found the LMS API, or it found it and Initialize returned false with an error code that says why.

What it means

Most SCORM launches start the same way: the course looks for the LMS's API object, usually by walking up its window hierarchy (window.API for SCORM 1.2, window.API_1484_11 for SCORM 2004), then calls LMSInitialize("") or Initialize("") on it. "LMSInitialize failed" is how many course wrappers and LMS logs report that this did not happen; the exact wording varies by wrapper. There are two quite different failures behind it. In the first, the API was never found, so no SCORM call reached the LMS at all and there is no error code to read. In the second, the call reached the LMS and returned "false": the error code set straight after it (what GetLastError returns) names the reason. In SCORM 1.2 that is 201 when an argument other than an empty string was passed, and 101 when the session was already initialized or already finished. SCORM 2004 is more specific: 201 for a bad argument, 103 Already Initialized, 104 Content Instance Terminated. The 2004 standard also defines 102, General Initialization Failure, but the runtime SCORM Lab uses does not return it from Initialize.

Which authoring tools produce it

Not tied to one authoring tool. API-not-found usually comes from a course published for one SCORM version and run as the other (a 2004 course looks for API_1484_11, a 1.2 LMS only offers API), from a launch page that opens the course in a new window or cross-origin frame the discovery code cannot climb out of, or from a hand-rolled discovery loop that only checks window.parent once. A false return is usually a second Initialize from a wrapper layered on top of the authoring tool’s own runtime, or a course that re-initializes after it has already terminated.

How to confirm it in SCORM Lab

Open the Transcript tab. A launch that works starts with an Initialize row returning true. A rejected Initialize gets no row of its own, so read what is around where it should be. GetValue rows failing with 301 (SCORM 1.2) or 122 (SCORM 2004) and no Initialize row mean the course is reading data but its session never opened. No rows at all mean the course never reached the API, or never got as far as calling it: check the Manifest preview's version badge against the version the course was published for, then the Console tab for the course's own messages (wrappers often log "LMSInitialize failed" or similar there) and for a script error that stopped it early. An Initialize row returning true followed by GetValue rows reporting 101 (SCORM 1.2) or 103 (SCORM 2004) means a second Initialize was rejected after the first one worked: see the duplicate-Initialize page below.

The fix

For API-not-found, republish for the SCORM version the LMS and manifest declare, and launch the course from the manifest's own launch file rather than a wrapper page that opens it elsewhere. If the discovery code is your own, walk up window.parent to a bounded depth, then try window.opener, and fail visibly if neither has the API. For a false return, act on the code: pass an empty string to Initialize, and make sure exactly one layer of the course calls it, once per launch.

A minimal launch that works, and the failures to compare it with

This is the start of a healthy SCORM 1.2 launch, followed by calls that fail and the error codes SCORM Lab returns for them. A rejected Initialize gets no Transcript row of its own; it shows up in the rows that follow it:

// SCORM 1.2: a launch that opens its session
LMSInitialize("")                        // "true", error 0
LMSGetValue("cmi.core.lesson_status")    // "not attempted", error 0

// SCORM 1.2 failures
LMSInitialize("1")                       // "false", error 201: the argument must be ""
LMSInitialize("")  // a second time      // "false", error 101: LMS was already initialized!
LMSGetValue(...)   // before Initialize  // error 301: Not initialized
LMSGetValue(...)   // after the duplicate // still reports 101 until a SetValue succeeds

// SCORM 2004 failures
Initialize("")     // a second time      // "false", error 103: Already Initialized
Initialize("")     // after Terminate    // "false", error 104: Content Instance Terminated
GetValue(...)      // before Initialize  // error 122: Retrieve Data Before Initialization

If the Transcript has no rows at all, none of these codes apply: the course never reached the API. That is the API-not-found case above.

Worth knowing

A failed Initialize does not always end the session. A duplicate call leaves the first session open, and after a 201 a corrected Initialize can still open it. One trap: after a duplicate, the runtime keeps reporting 101 or 103 on later reads that worked, until the next successful SetValue clears it. A read showing that code can be fine; the Initialize before it is the real problem.

Initialize returned false with “LMS was already initialized!”? Fix a duplicate Initialize call.

A SCORM 1.2 course failing to read cmi.learner_id? Fix a SCORM 2004 element on a SCORM 1.2 package.

SCORM Lab flags this as a check too: a SCO that never calls Initialize.

A pause on launch before the first call? Slow LMS API discovery.